hyperv_net.h 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. *
  4. * Copyright (c) 2011, Microsoft Corporation.
  5. *
  6. * Authors:
  7. * Haiyang Zhang <[email protected]>
  8. * Hank Janssen <[email protected]>
  9. * K. Y. Srinivasan <[email protected]>
  10. */
  11. #ifndef _HYPERV_NET_H
  12. #define _HYPERV_NET_H
  13. #include <linux/list.h>
  14. #include <linux/hyperv.h>
  15. #include <linux/rndis.h>
  16. #include <linux/jhash.h>
  17. /* RSS related */
  18. #define OID_GEN_RECEIVE_SCALE_CAPABILITIES 0x00010203 /* query only */
  19. #define OID_GEN_RECEIVE_SCALE_PARAMETERS 0x00010204 /* query and set */
  20. #define NDIS_OBJECT_TYPE_RSS_CAPABILITIES 0x88
  21. #define NDIS_OBJECT_TYPE_RSS_PARAMETERS 0x89
  22. #define NDIS_OBJECT_TYPE_OFFLOAD 0xa7
  23. #define NDIS_RECEIVE_SCALE_CAPABILITIES_REVISION_2 2
  24. #define NDIS_RECEIVE_SCALE_PARAMETERS_REVISION_2 2
  25. struct ndis_obj_header {
  26. u8 type;
  27. u8 rev;
  28. u16 size;
  29. } __packed;
  30. /* ndis_recv_scale_cap/cap_flag */
  31. #define NDIS_RSS_CAPS_MESSAGE_SIGNALED_INTERRUPTS 0x01000000
  32. #define NDIS_RSS_CAPS_CLASSIFICATION_AT_ISR 0x02000000
  33. #define NDIS_RSS_CAPS_CLASSIFICATION_AT_DPC 0x04000000
  34. #define NDIS_RSS_CAPS_USING_MSI_X 0x08000000
  35. #define NDIS_RSS_CAPS_RSS_AVAILABLE_ON_PORTS 0x10000000
  36. #define NDIS_RSS_CAPS_SUPPORTS_MSI_X 0x20000000
  37. #define NDIS_RSS_CAPS_HASH_TYPE_TCP_IPV4 0x00000100
  38. #define NDIS_RSS_CAPS_HASH_TYPE_TCP_IPV6 0x00000200
  39. #define NDIS_RSS_CAPS_HASH_TYPE_TCP_IPV6_EX 0x00000400
  40. struct ndis_recv_scale_cap { /* NDIS_RECEIVE_SCALE_CAPABILITIES */
  41. struct ndis_obj_header hdr;
  42. u32 cap_flag;
  43. u32 num_int_msg;
  44. u32 num_recv_que;
  45. u16 num_indirect_tabent;
  46. } __packed;
  47. /* ndis_recv_scale_param flags */
  48. #define NDIS_RSS_PARAM_FLAG_BASE_CPU_UNCHANGED 0x0001
  49. #define NDIS_RSS_PARAM_FLAG_HASH_INFO_UNCHANGED 0x0002
  50. #define NDIS_RSS_PARAM_FLAG_ITABLE_UNCHANGED 0x0004
  51. #define NDIS_RSS_PARAM_FLAG_HASH_KEY_UNCHANGED 0x0008
  52. #define NDIS_RSS_PARAM_FLAG_DISABLE_RSS 0x0010
  53. /* Hash info bits */
  54. #define NDIS_HASH_FUNC_TOEPLITZ 0x00000001
  55. #define NDIS_HASH_IPV4 0x00000100
  56. #define NDIS_HASH_TCP_IPV4 0x00000200
  57. #define NDIS_HASH_IPV6 0x00000400
  58. #define NDIS_HASH_IPV6_EX 0x00000800
  59. #define NDIS_HASH_TCP_IPV6 0x00001000
  60. #define NDIS_HASH_TCP_IPV6_EX 0x00002000
  61. #define NDIS_RSS_INDIRECTION_TABLE_MAX_SIZE_REVISION_2 (128 * 4)
  62. #define NDIS_RSS_HASH_SECRET_KEY_MAX_SIZE_REVISION_2 40
  63. #define ITAB_NUM 128
  64. struct ndis_recv_scale_param { /* NDIS_RECEIVE_SCALE_PARAMETERS */
  65. struct ndis_obj_header hdr;
  66. /* Qualifies the rest of the information */
  67. u16 flag;
  68. /* The base CPU number to do receive processing. not used */
  69. u16 base_cpu_number;
  70. /* This describes the hash function and type being enabled */
  71. u32 hashinfo;
  72. /* The size of indirection table array */
  73. u16 indirect_tabsize;
  74. /* The offset of the indirection table from the beginning of this
  75. * structure
  76. */
  77. u32 indirect_taboffset;
  78. /* The size of the hash secret key */
  79. u16 hashkey_size;
  80. /* The offset of the secret key from the beginning of this structure */
  81. u32 hashkey_offset;
  82. u32 processor_masks_offset;
  83. u32 num_processor_masks;
  84. u32 processor_masks_entry_size;
  85. };
  86. struct ndis_tcp_ip_checksum_info {
  87. union {
  88. struct {
  89. u32 is_ipv4:1;
  90. u32 is_ipv6:1;
  91. u32 tcp_checksum:1;
  92. u32 udp_checksum:1;
  93. u32 ip_header_checksum:1;
  94. u32 reserved:11;
  95. u32 tcp_header_offset:10;
  96. } transmit;
  97. struct {
  98. u32 tcp_checksum_failed:1;
  99. u32 udp_checksum_failed:1;
  100. u32 ip_checksum_failed:1;
  101. u32 tcp_checksum_succeeded:1;
  102. u32 udp_checksum_succeeded:1;
  103. u32 ip_checksum_succeeded:1;
  104. u32 loopback:1;
  105. u32 tcp_checksum_value_invalid:1;
  106. u32 ip_checksum_value_invalid:1;
  107. } receive;
  108. u32 value;
  109. };
  110. };
  111. struct ndis_pkt_8021q_info {
  112. union {
  113. struct {
  114. u32 pri:3; /* User Priority */
  115. u32 cfi:1; /* Canonical Format ID */
  116. u32 vlanid:12; /* VLAN ID */
  117. u32 reserved:16;
  118. };
  119. u32 value;
  120. };
  121. };
  122. /*
  123. * Represent netvsc packet which contains 1 RNDIS and 1 ethernet frame
  124. * within the RNDIS
  125. *
  126. * The size of this structure is less than 48 bytes and we can now
  127. * place this structure in the skb->cb field.
  128. */
  129. struct hv_netvsc_packet {
  130. /* Bookkeeping stuff */
  131. u8 cp_partial; /* partial copy into send buffer */
  132. u8 rmsg_size; /* RNDIS header and PPI size */
  133. u8 rmsg_pgcnt; /* page count of RNDIS header and PPI */
  134. u8 page_buf_cnt;
  135. u16 q_idx;
  136. u16 total_packets;
  137. u32 total_bytes;
  138. u32 send_buf_index;
  139. u32 total_data_buflen;
  140. struct hv_dma_range *dma_range;
  141. };
  142. #define NETVSC_HASH_KEYLEN 40
  143. struct netvsc_device_info {
  144. unsigned char mac_adr[ETH_ALEN];
  145. u32 num_chn;
  146. u32 send_sections;
  147. u32 recv_sections;
  148. u32 send_section_size;
  149. u32 recv_section_size;
  150. struct bpf_prog *bprog;
  151. u8 rss_key[NETVSC_HASH_KEYLEN];
  152. };
  153. enum rndis_device_state {
  154. RNDIS_DEV_UNINITIALIZED = 0,
  155. RNDIS_DEV_INITIALIZING,
  156. RNDIS_DEV_INITIALIZED,
  157. RNDIS_DEV_DATAINITIALIZED,
  158. };
  159. struct rndis_device {
  160. struct net_device *ndev;
  161. enum rndis_device_state state;
  162. atomic_t new_req_id;
  163. spinlock_t request_lock;
  164. struct list_head req_list;
  165. struct work_struct mcast_work;
  166. u32 filter;
  167. bool link_state; /* 0 - link up, 1 - link down */
  168. u8 hw_mac_adr[ETH_ALEN];
  169. u8 rss_key[NETVSC_HASH_KEYLEN];
  170. };
  171. /* Interface */
  172. struct rndis_message;
  173. struct ndis_offload_params;
  174. struct netvsc_device;
  175. struct netvsc_channel;
  176. struct net_device_context;
  177. extern u32 netvsc_ring_bytes;
  178. struct netvsc_device *netvsc_device_add(struct hv_device *device,
  179. const struct netvsc_device_info *info);
  180. int netvsc_alloc_recv_comp_ring(struct netvsc_device *net_device, u32 q_idx);
  181. void netvsc_device_remove(struct hv_device *device);
  182. int netvsc_send(struct net_device *net,
  183. struct hv_netvsc_packet *packet,
  184. struct rndis_message *rndis_msg,
  185. struct hv_page_buffer *page_buffer,
  186. struct sk_buff *skb,
  187. bool xdp_tx);
  188. void netvsc_linkstatus_callback(struct net_device *net,
  189. struct rndis_message *resp,
  190. void *data, u32 data_buflen);
  191. int netvsc_recv_callback(struct net_device *net,
  192. struct netvsc_device *nvdev,
  193. struct netvsc_channel *nvchan);
  194. void netvsc_channel_cb(void *context);
  195. int netvsc_poll(struct napi_struct *napi, int budget);
  196. void netvsc_xdp_xmit(struct sk_buff *skb, struct net_device *ndev);
  197. u32 netvsc_run_xdp(struct net_device *ndev, struct netvsc_channel *nvchan,
  198. struct xdp_buff *xdp);
  199. unsigned int netvsc_xdp_fraglen(unsigned int len);
  200. struct bpf_prog *netvsc_xdp_get(struct netvsc_device *nvdev);
  201. int netvsc_xdp_set(struct net_device *dev, struct bpf_prog *prog,
  202. struct netlink_ext_ack *extack,
  203. struct netvsc_device *nvdev);
  204. int netvsc_vf_setxdp(struct net_device *vf_netdev, struct bpf_prog *prog);
  205. int netvsc_bpf(struct net_device *dev, struct netdev_bpf *bpf);
  206. int netvsc_ndoxdp_xmit(struct net_device *ndev, int n,
  207. struct xdp_frame **frames, u32 flags);
  208. int rndis_set_subchannel(struct net_device *ndev,
  209. struct netvsc_device *nvdev,
  210. struct netvsc_device_info *dev_info);
  211. int rndis_filter_open(struct netvsc_device *nvdev);
  212. int rndis_filter_close(struct netvsc_device *nvdev);
  213. struct netvsc_device *rndis_filter_device_add(struct hv_device *dev,
  214. struct netvsc_device_info *info);
  215. void rndis_filter_update(struct netvsc_device *nvdev);
  216. void rndis_filter_device_remove(struct hv_device *dev,
  217. struct netvsc_device *nvdev);
  218. int rndis_filter_set_rss_param(struct rndis_device *rdev,
  219. const u8 *key);
  220. int rndis_filter_set_offload_params(struct net_device *ndev,
  221. struct netvsc_device *nvdev,
  222. struct ndis_offload_params *req_offloads);
  223. int rndis_filter_receive(struct net_device *ndev,
  224. struct netvsc_device *net_dev,
  225. struct netvsc_channel *nvchan,
  226. void *data, u32 buflen);
  227. int rndis_filter_set_device_mac(struct netvsc_device *ndev,
  228. const char *mac);
  229. int netvsc_switch_datapath(struct net_device *nv_dev, bool vf);
  230. #define NVSP_INVALID_PROTOCOL_VERSION ((u32)0xFFFFFFFF)
  231. #define NVSP_PROTOCOL_VERSION_1 2
  232. #define NVSP_PROTOCOL_VERSION_2 0x30002
  233. #define NVSP_PROTOCOL_VERSION_4 0x40000
  234. #define NVSP_PROTOCOL_VERSION_5 0x50000
  235. #define NVSP_PROTOCOL_VERSION_6 0x60000
  236. #define NVSP_PROTOCOL_VERSION_61 0x60001
  237. enum {
  238. NVSP_MSG_TYPE_NONE = 0,
  239. /* Init Messages */
  240. NVSP_MSG_TYPE_INIT = 1,
  241. NVSP_MSG_TYPE_INIT_COMPLETE = 2,
  242. NVSP_VERSION_MSG_START = 100,
  243. /* Version 1 Messages */
  244. NVSP_MSG1_TYPE_SEND_NDIS_VER = NVSP_VERSION_MSG_START,
  245. NVSP_MSG1_TYPE_SEND_RECV_BUF,
  246. NVSP_MSG1_TYPE_SEND_RECV_BUF_COMPLETE,
  247. NVSP_MSG1_TYPE_REVOKE_RECV_BUF,
  248. NVSP_MSG1_TYPE_SEND_SEND_BUF,
  249. NVSP_MSG1_TYPE_SEND_SEND_BUF_COMPLETE,
  250. NVSP_MSG1_TYPE_REVOKE_SEND_BUF,
  251. NVSP_MSG1_TYPE_SEND_RNDIS_PKT,
  252. NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE,
  253. /* Version 2 messages */
  254. NVSP_MSG2_TYPE_SEND_CHIMNEY_DELEGATED_BUF,
  255. NVSP_MSG2_TYPE_SEND_CHIMNEY_DELEGATED_BUF_COMP,
  256. NVSP_MSG2_TYPE_REVOKE_CHIMNEY_DELEGATED_BUF,
  257. NVSP_MSG2_TYPE_RESUME_CHIMNEY_RX_INDICATION,
  258. NVSP_MSG2_TYPE_TERMINATE_CHIMNEY,
  259. NVSP_MSG2_TYPE_TERMINATE_CHIMNEY_COMP,
  260. NVSP_MSG2_TYPE_INDICATE_CHIMNEY_EVENT,
  261. NVSP_MSG2_TYPE_SEND_CHIMNEY_PKT,
  262. NVSP_MSG2_TYPE_SEND_CHIMNEY_PKT_COMP,
  263. NVSP_MSG2_TYPE_POST_CHIMNEY_RECV_REQ,
  264. NVSP_MSG2_TYPE_POST_CHIMNEY_RECV_REQ_COMP,
  265. NVSP_MSG2_TYPE_ALLOC_RXBUF,
  266. NVSP_MSG2_TYPE_ALLOC_RXBUF_COMP,
  267. NVSP_MSG2_TYPE_FREE_RXBUF,
  268. NVSP_MSG2_TYPE_SEND_VMQ_RNDIS_PKT,
  269. NVSP_MSG2_TYPE_SEND_VMQ_RNDIS_PKT_COMP,
  270. NVSP_MSG2_TYPE_SEND_NDIS_CONFIG,
  271. NVSP_MSG2_TYPE_ALLOC_CHIMNEY_HANDLE,
  272. NVSP_MSG2_TYPE_ALLOC_CHIMNEY_HANDLE_COMP,
  273. NVSP_MSG2_MAX = NVSP_MSG2_TYPE_ALLOC_CHIMNEY_HANDLE_COMP,
  274. /* Version 4 messages */
  275. NVSP_MSG4_TYPE_SEND_VF_ASSOCIATION,
  276. NVSP_MSG4_TYPE_SWITCH_DATA_PATH,
  277. NVSP_MSG4_TYPE_UPLINK_CONNECT_STATE_DEPRECATED,
  278. NVSP_MSG4_MAX = NVSP_MSG4_TYPE_UPLINK_CONNECT_STATE_DEPRECATED,
  279. /* Version 5 messages */
  280. NVSP_MSG5_TYPE_OID_QUERY_EX,
  281. NVSP_MSG5_TYPE_OID_QUERY_EX_COMP,
  282. NVSP_MSG5_TYPE_SUBCHANNEL,
  283. NVSP_MSG5_TYPE_SEND_INDIRECTION_TABLE,
  284. NVSP_MSG5_MAX = NVSP_MSG5_TYPE_SEND_INDIRECTION_TABLE,
  285. /* Version 6 messages */
  286. NVSP_MSG6_TYPE_PD_API,
  287. NVSP_MSG6_TYPE_PD_POST_BATCH,
  288. NVSP_MSG6_MAX = NVSP_MSG6_TYPE_PD_POST_BATCH
  289. };
  290. enum {
  291. NVSP_STAT_NONE = 0,
  292. NVSP_STAT_SUCCESS,
  293. NVSP_STAT_FAIL,
  294. NVSP_STAT_PROTOCOL_TOO_NEW,
  295. NVSP_STAT_PROTOCOL_TOO_OLD,
  296. NVSP_STAT_INVALID_RNDIS_PKT,
  297. NVSP_STAT_BUSY,
  298. NVSP_STAT_PROTOCOL_UNSUPPORTED,
  299. NVSP_STAT_MAX,
  300. };
  301. struct nvsp_message_header {
  302. u32 msg_type;
  303. };
  304. /* Init Messages */
  305. /*
  306. * This message is used by the VSC to initialize the channel after the channels
  307. * has been opened. This message should never include anything other then
  308. * versioning (i.e. this message will be the same for ever).
  309. */
  310. struct nvsp_message_init {
  311. u32 min_protocol_ver;
  312. u32 max_protocol_ver;
  313. } __packed;
  314. /*
  315. * This message is used by the VSP to complete the initialization of the
  316. * channel. This message should never include anything other then versioning
  317. * (i.e. this message will be the same for ever).
  318. */
  319. struct nvsp_message_init_complete {
  320. u32 negotiated_protocol_ver;
  321. u32 max_mdl_chain_len;
  322. u32 status;
  323. } __packed;
  324. union nvsp_message_init_uber {
  325. struct nvsp_message_init init;
  326. struct nvsp_message_init_complete init_complete;
  327. } __packed;
  328. /* Version 1 Messages */
  329. /*
  330. * This message is used by the VSC to send the NDIS version to the VSP. The VSP
  331. * can use this information when handling OIDs sent by the VSC.
  332. */
  333. struct nvsp_1_message_send_ndis_version {
  334. u32 ndis_major_ver;
  335. u32 ndis_minor_ver;
  336. } __packed;
  337. /*
  338. * This message is used by the VSC to send a receive buffer to the VSP. The VSP
  339. * can then use the receive buffer to send data to the VSC.
  340. */
  341. struct nvsp_1_message_send_receive_buffer {
  342. u32 gpadl_handle;
  343. u16 id;
  344. } __packed;
  345. struct nvsp_1_receive_buffer_section {
  346. u32 offset;
  347. u32 sub_alloc_size;
  348. u32 num_sub_allocs;
  349. u32 end_offset;
  350. } __packed;
  351. /*
  352. * This message is used by the VSP to acknowledge a receive buffer send by the
  353. * VSC. This message must be sent by the VSP before the VSP uses the receive
  354. * buffer.
  355. */
  356. struct nvsp_1_message_send_receive_buffer_complete {
  357. u32 status;
  358. u32 num_sections;
  359. /*
  360. * The receive buffer is split into two parts, a large suballocation
  361. * section and a small suballocation section. These sections are then
  362. * suballocated by a certain size.
  363. */
  364. /*
  365. * For example, the following break up of the receive buffer has 6
  366. * large suballocations and 10 small suballocations.
  367. */
  368. /*
  369. * | Large Section | | Small Section |
  370. * ------------------------------------------------------------
  371. * | | | | | | | | | | | | | | | | | |
  372. * | |
  373. * LargeOffset SmallOffset
  374. */
  375. struct nvsp_1_receive_buffer_section sections[1];
  376. } __packed;
  377. /*
  378. * This message is sent by the VSC to revoke the receive buffer. After the VSP
  379. * completes this transaction, the vsp should never use the receive buffer
  380. * again.
  381. */
  382. struct nvsp_1_message_revoke_receive_buffer {
  383. u16 id;
  384. };
  385. /*
  386. * This message is used by the VSC to send a send buffer to the VSP. The VSC
  387. * can then use the send buffer to send data to the VSP.
  388. */
  389. struct nvsp_1_message_send_send_buffer {
  390. u32 gpadl_handle;
  391. u16 id;
  392. } __packed;
  393. /*
  394. * This message is used by the VSP to acknowledge a send buffer sent by the
  395. * VSC. This message must be sent by the VSP before the VSP uses the sent
  396. * buffer.
  397. */
  398. struct nvsp_1_message_send_send_buffer_complete {
  399. u32 status;
  400. /*
  401. * The VSC gets to choose the size of the send buffer and the VSP gets
  402. * to choose the sections size of the buffer. This was done to enable
  403. * dynamic reconfigurations when the cost of GPA-direct buffers
  404. * decreases.
  405. */
  406. u32 section_size;
  407. } __packed;
  408. /*
  409. * This message is sent by the VSC to revoke the send buffer. After the VSP
  410. * completes this transaction, the vsp should never use the send buffer again.
  411. */
  412. struct nvsp_1_message_revoke_send_buffer {
  413. u16 id;
  414. };
  415. /*
  416. * This message is used by both the VSP and the VSC to send a RNDIS message to
  417. * the opposite channel endpoint.
  418. */
  419. struct nvsp_1_message_send_rndis_packet {
  420. /*
  421. * This field is specified by RNDIS. They assume there's two different
  422. * channels of communication. However, the Network VSP only has one.
  423. * Therefore, the channel travels with the RNDIS packet.
  424. */
  425. u32 channel_type;
  426. /*
  427. * This field is used to send part or all of the data through a send
  428. * buffer. This values specifies an index into the send buffer. If the
  429. * index is 0xFFFFFFFF, then the send buffer is not being used and all
  430. * of the data was sent through other VMBus mechanisms.
  431. */
  432. u32 send_buf_section_index;
  433. u32 send_buf_section_size;
  434. } __packed;
  435. /*
  436. * This message is used by both the VSP and the VSC to complete a RNDIS message
  437. * to the opposite channel endpoint. At this point, the initiator of this
  438. * message cannot use any resources associated with the original RNDIS packet.
  439. */
  440. struct nvsp_1_message_send_rndis_packet_complete {
  441. u32 status;
  442. };
  443. union nvsp_1_message_uber {
  444. struct nvsp_1_message_send_ndis_version send_ndis_ver;
  445. struct nvsp_1_message_send_receive_buffer send_recv_buf;
  446. struct nvsp_1_message_send_receive_buffer_complete
  447. send_recv_buf_complete;
  448. struct nvsp_1_message_revoke_receive_buffer revoke_recv_buf;
  449. struct nvsp_1_message_send_send_buffer send_send_buf;
  450. struct nvsp_1_message_send_send_buffer_complete send_send_buf_complete;
  451. struct nvsp_1_message_revoke_send_buffer revoke_send_buf;
  452. struct nvsp_1_message_send_rndis_packet send_rndis_pkt;
  453. struct nvsp_1_message_send_rndis_packet_complete
  454. send_rndis_pkt_complete;
  455. } __packed;
  456. /*
  457. * Network VSP protocol version 2 messages:
  458. */
  459. struct nvsp_2_vsc_capability {
  460. union {
  461. u64 data;
  462. struct {
  463. u64 vmq:1;
  464. u64 chimney:1;
  465. u64 sriov:1;
  466. u64 ieee8021q:1;
  467. u64 correlation_id:1;
  468. u64 teaming:1;
  469. u64 vsubnetid:1;
  470. u64 rsc:1;
  471. };
  472. };
  473. } __packed;
  474. struct nvsp_2_send_ndis_config {
  475. u32 mtu;
  476. u32 reserved;
  477. struct nvsp_2_vsc_capability capability;
  478. } __packed;
  479. /* Allocate receive buffer */
  480. struct nvsp_2_alloc_rxbuf {
  481. /* Allocation ID to match the allocation request and response */
  482. u32 alloc_id;
  483. /* Length of the VM shared memory receive buffer that needs to
  484. * be allocated
  485. */
  486. u32 len;
  487. } __packed;
  488. /* Allocate receive buffer complete */
  489. struct nvsp_2_alloc_rxbuf_comp {
  490. /* The NDIS_STATUS code for buffer allocation */
  491. u32 status;
  492. u32 alloc_id;
  493. /* GPADL handle for the allocated receive buffer */
  494. u32 gpadl_handle;
  495. /* Receive buffer ID */
  496. u64 recv_buf_id;
  497. } __packed;
  498. struct nvsp_2_free_rxbuf {
  499. u64 recv_buf_id;
  500. } __packed;
  501. union nvsp_2_message_uber {
  502. struct nvsp_2_send_ndis_config send_ndis_config;
  503. struct nvsp_2_alloc_rxbuf alloc_rxbuf;
  504. struct nvsp_2_alloc_rxbuf_comp alloc_rxbuf_comp;
  505. struct nvsp_2_free_rxbuf free_rxbuf;
  506. } __packed;
  507. struct nvsp_4_send_vf_association {
  508. /* 1: allocated, serial number is valid. 0: not allocated */
  509. u32 allocated;
  510. /* Serial number of the VF to team with */
  511. u32 serial;
  512. } __packed;
  513. enum nvsp_vm_datapath {
  514. NVSP_DATAPATH_SYNTHETIC = 0,
  515. NVSP_DATAPATH_VF,
  516. NVSP_DATAPATH_MAX
  517. };
  518. struct nvsp_4_sw_datapath {
  519. u32 active_datapath; /* active data path in VM */
  520. } __packed;
  521. union nvsp_4_message_uber {
  522. struct nvsp_4_send_vf_association vf_assoc;
  523. struct nvsp_4_sw_datapath active_dp;
  524. } __packed;
  525. enum nvsp_subchannel_operation {
  526. NVSP_SUBCHANNEL_NONE = 0,
  527. NVSP_SUBCHANNEL_ALLOCATE,
  528. NVSP_SUBCHANNEL_MAX
  529. };
  530. struct nvsp_5_subchannel_request {
  531. u32 op;
  532. u32 num_subchannels;
  533. } __packed;
  534. struct nvsp_5_subchannel_complete {
  535. u32 status;
  536. u32 num_subchannels; /* Actual number of subchannels allocated */
  537. } __packed;
  538. struct nvsp_5_send_indirect_table {
  539. /* The number of entries in the send indirection table */
  540. u32 count;
  541. /* The offset of the send indirection table from the beginning of
  542. * struct nvsp_message.
  543. * The send indirection table tells which channel to put the send
  544. * traffic on. Each entry is a channel number.
  545. */
  546. u32 offset;
  547. } __packed;
  548. union nvsp_5_message_uber {
  549. struct nvsp_5_subchannel_request subchn_req;
  550. struct nvsp_5_subchannel_complete subchn_comp;
  551. struct nvsp_5_send_indirect_table send_table;
  552. } __packed;
  553. enum nvsp_6_pd_api_op {
  554. PD_API_OP_CONFIG = 1,
  555. PD_API_OP_SW_DATAPATH, /* Switch Datapath */
  556. PD_API_OP_OPEN_PROVIDER,
  557. PD_API_OP_CLOSE_PROVIDER,
  558. PD_API_OP_CREATE_QUEUE,
  559. PD_API_OP_FLUSH_QUEUE,
  560. PD_API_OP_FREE_QUEUE,
  561. PD_API_OP_ALLOC_COM_BUF, /* Allocate Common Buffer */
  562. PD_API_OP_FREE_COM_BUF, /* Free Common Buffer */
  563. PD_API_OP_MAX
  564. };
  565. struct grp_affinity {
  566. u64 mask;
  567. u16 grp;
  568. u16 reserved[3];
  569. } __packed;
  570. struct nvsp_6_pd_api_req {
  571. u32 op;
  572. union {
  573. /* MMIO information is sent from the VM to VSP */
  574. struct __packed {
  575. u64 mmio_pa; /* MMIO Physical Address */
  576. u32 mmio_len;
  577. /* Number of PD queues a VM can support */
  578. u16 num_subchn;
  579. } config;
  580. /* Switch Datapath */
  581. struct __packed {
  582. /* Host Datapath Is PacketDirect */
  583. u8 host_dpath_is_pd;
  584. /* Guest PacketDirect Is Enabled */
  585. u8 guest_pd_enabled;
  586. } sw_dpath;
  587. /* Open Provider*/
  588. struct __packed {
  589. u32 prov_id; /* Provider id */
  590. u32 flag;
  591. } open_prov;
  592. /* Close Provider */
  593. struct __packed {
  594. u32 prov_id;
  595. } cls_prov;
  596. /* Create Queue*/
  597. struct __packed {
  598. u32 prov_id;
  599. u16 q_id;
  600. u16 q_size;
  601. u8 is_recv_q;
  602. u8 is_rss_q;
  603. u32 recv_data_len;
  604. struct grp_affinity affy;
  605. } cr_q;
  606. /* Delete Queue*/
  607. struct __packed {
  608. u32 prov_id;
  609. u16 q_id;
  610. } del_q;
  611. /* Flush Queue */
  612. struct __packed {
  613. u32 prov_id;
  614. u16 q_id;
  615. } flush_q;
  616. /* Allocate Common Buffer */
  617. struct __packed {
  618. u32 len;
  619. u32 pf_node; /* Preferred Node */
  620. u16 region_id;
  621. } alloc_com_buf;
  622. /* Free Common Buffer */
  623. struct __packed {
  624. u32 len;
  625. u64 pa; /* Physical Address */
  626. u32 pf_node; /* Preferred Node */
  627. u16 region_id;
  628. u8 cache_type;
  629. } free_com_buf;
  630. } __packed;
  631. } __packed;
  632. struct nvsp_6_pd_api_comp {
  633. u32 op;
  634. u32 status;
  635. union {
  636. struct __packed {
  637. /* actual number of PD queues allocated to the VM */
  638. u16 num_pd_q;
  639. /* Num Receive Rss PD Queues */
  640. u8 num_rss_q;
  641. u8 is_supported; /* Is supported by VSP */
  642. u8 is_enabled; /* Is enabled by VSP */
  643. } config;
  644. /* Open Provider */
  645. struct __packed {
  646. u32 prov_id;
  647. } open_prov;
  648. /* Create Queue */
  649. struct __packed {
  650. u32 prov_id;
  651. u16 q_id;
  652. u16 q_size;
  653. u32 recv_data_len;
  654. struct grp_affinity affy;
  655. } cr_q;
  656. /* Allocate Common Buffer */
  657. struct __packed {
  658. u64 pa; /* Physical Address */
  659. u32 len;
  660. u32 pf_node; /* Preferred Node */
  661. u16 region_id;
  662. u8 cache_type;
  663. } alloc_com_buf;
  664. } __packed;
  665. } __packed;
  666. struct nvsp_6_pd_buf {
  667. u32 region_offset;
  668. u16 region_id;
  669. u16 is_partial:1;
  670. u16 reserved:15;
  671. } __packed;
  672. struct nvsp_6_pd_batch_msg {
  673. struct nvsp_message_header hdr;
  674. u16 count;
  675. u16 guest2host:1;
  676. u16 is_recv:1;
  677. u16 reserved:14;
  678. struct nvsp_6_pd_buf pd_buf[0];
  679. } __packed;
  680. union nvsp_6_message_uber {
  681. struct nvsp_6_pd_api_req pd_req;
  682. struct nvsp_6_pd_api_comp pd_comp;
  683. } __packed;
  684. union nvsp_all_messages {
  685. union nvsp_message_init_uber init_msg;
  686. union nvsp_1_message_uber v1_msg;
  687. union nvsp_2_message_uber v2_msg;
  688. union nvsp_4_message_uber v4_msg;
  689. union nvsp_5_message_uber v5_msg;
  690. union nvsp_6_message_uber v6_msg;
  691. } __packed;
  692. /* ALL Messages */
  693. struct nvsp_message {
  694. struct nvsp_message_header hdr;
  695. union nvsp_all_messages msg;
  696. } __packed;
  697. #define NETVSC_MTU 65535
  698. #define NETVSC_MTU_MIN ETH_MIN_MTU
  699. /* Max buffer sizes allowed by a host */
  700. #define NETVSC_RECEIVE_BUFFER_SIZE (1024 * 1024 * 31) /* 31MB */
  701. #define NETVSC_RECEIVE_BUFFER_SIZE_LEGACY (1024 * 1024 * 15) /* 15MB */
  702. #define NETVSC_RECEIVE_BUFFER_DEFAULT (1024 * 1024 * 16)
  703. #define NETVSC_SEND_BUFFER_SIZE (1024 * 1024 * 15) /* 15MB */
  704. #define NETVSC_SEND_BUFFER_DEFAULT (1024 * 1024)
  705. #define NETVSC_INVALID_INDEX -1
  706. #define NETVSC_SEND_SECTION_SIZE 6144
  707. #define NETVSC_RECV_SECTION_SIZE 1728
  708. /* Default size of TX buf: 1MB, RX buf: 16MB */
  709. #define NETVSC_MIN_TX_SECTIONS 10
  710. #define NETVSC_DEFAULT_TX (NETVSC_SEND_BUFFER_DEFAULT \
  711. / NETVSC_SEND_SECTION_SIZE)
  712. #define NETVSC_MIN_RX_SECTIONS 10
  713. #define NETVSC_DEFAULT_RX (NETVSC_RECEIVE_BUFFER_DEFAULT \
  714. / NETVSC_RECV_SECTION_SIZE)
  715. #define NETVSC_RECEIVE_BUFFER_ID 0xcafe
  716. #define NETVSC_SEND_BUFFER_ID 0
  717. #define NETVSC_SUPPORTED_HW_FEATURES (NETIF_F_RXCSUM | NETIF_F_IP_CSUM | \
  718. NETIF_F_TSO | NETIF_F_IPV6_CSUM | \
  719. NETIF_F_TSO6 | NETIF_F_LRO | \
  720. NETIF_F_SG | NETIF_F_RXHASH)
  721. #define VRSS_SEND_TAB_SIZE 16 /* must be power of 2 */
  722. #define VRSS_CHANNEL_MAX 64
  723. #define VRSS_CHANNEL_DEFAULT 8
  724. #define RNDIS_MAX_PKT_DEFAULT 8
  725. #define RNDIS_PKT_ALIGN_DEFAULT 8
  726. #define NETVSC_XDP_HDRM 256
  727. #define NETVSC_MIN_OUT_MSG_SIZE (sizeof(struct vmpacket_descriptor) + \
  728. sizeof(struct nvsp_message))
  729. #define NETVSC_MIN_IN_MSG_SIZE sizeof(struct vmpacket_descriptor)
  730. /* Estimated requestor size:
  731. * out_ring_size/min_out_msg_size + in_ring_size/min_in_msg_size
  732. */
  733. static inline u32 netvsc_rqstor_size(unsigned long ringbytes)
  734. {
  735. return ringbytes / NETVSC_MIN_OUT_MSG_SIZE +
  736. ringbytes / NETVSC_MIN_IN_MSG_SIZE;
  737. }
  738. /* XFER PAGE packets can specify a maximum of 375 ranges for NDIS >= 6.0
  739. * and a maximum of 64 ranges for NDIS < 6.0 with no RSC; with RSC, this
  740. * limit is raised to 562 (= NVSP_RSC_MAX).
  741. */
  742. #define NETVSC_MAX_XFER_PAGE_RANGES NVSP_RSC_MAX
  743. #define NETVSC_XFER_HEADER_SIZE(rng_cnt) \
  744. (offsetof(struct vmtransfer_page_packet_header, ranges) + \
  745. (rng_cnt) * sizeof(struct vmtransfer_page_range))
  746. #define NETVSC_MAX_PKT_SIZE (NETVSC_XFER_HEADER_SIZE(NETVSC_MAX_XFER_PAGE_RANGES) + \
  747. sizeof(struct nvsp_message) + (sizeof(u32) * VRSS_SEND_TAB_SIZE))
  748. struct multi_send_data {
  749. struct sk_buff *skb; /* skb containing the pkt */
  750. struct hv_netvsc_packet *pkt; /* netvsc pkt pending */
  751. u32 count; /* counter of batched packets */
  752. };
  753. struct recv_comp_data {
  754. u64 tid; /* transaction id */
  755. u32 status;
  756. };
  757. struct multi_recv_comp {
  758. struct recv_comp_data *slots;
  759. u32 first; /* first data entry */
  760. u32 next; /* next entry for writing */
  761. };
  762. #define NVSP_RSC_MAX 562 /* Max #RSC frags in a vmbus xfer page pkt */
  763. struct nvsc_rsc {
  764. struct ndis_pkt_8021q_info vlan;
  765. struct ndis_tcp_ip_checksum_info csum_info;
  766. u32 hash_info;
  767. u8 ppi_flags; /* valid/present bits for the above PPIs */
  768. u8 is_last; /* last RNDIS msg in a vmtransfer_page */
  769. u32 cnt; /* #fragments in an RSC packet */
  770. u32 pktlen; /* Full packet length */
  771. void *data[NVSP_RSC_MAX];
  772. u32 len[NVSP_RSC_MAX];
  773. };
  774. #define NVSC_RSC_VLAN BIT(0) /* valid/present bit for 'vlan' */
  775. #define NVSC_RSC_CSUM_INFO BIT(1) /* valid/present bit for 'csum_info' */
  776. #define NVSC_RSC_HASH_INFO BIT(2) /* valid/present bit for 'hash_info' */
  777. struct netvsc_stats_tx {
  778. u64 packets;
  779. u64 bytes;
  780. u64 xdp_xmit;
  781. struct u64_stats_sync syncp;
  782. };
  783. struct netvsc_stats_rx {
  784. u64 packets;
  785. u64 bytes;
  786. u64 broadcast;
  787. u64 multicast;
  788. u64 xdp_drop;
  789. u64 xdp_redirect;
  790. u64 xdp_tx;
  791. struct u64_stats_sync syncp;
  792. };
  793. struct netvsc_ethtool_stats {
  794. unsigned long tx_scattered;
  795. unsigned long tx_no_memory;
  796. unsigned long tx_no_space;
  797. unsigned long tx_too_big;
  798. unsigned long tx_busy;
  799. unsigned long tx_send_full;
  800. unsigned long rx_comp_busy;
  801. unsigned long rx_no_memory;
  802. unsigned long stop_queue;
  803. unsigned long wake_queue;
  804. unsigned long vlan_error;
  805. };
  806. struct netvsc_ethtool_pcpu_stats {
  807. u64 rx_packets;
  808. u64 rx_bytes;
  809. u64 tx_packets;
  810. u64 tx_bytes;
  811. u64 vf_rx_packets;
  812. u64 vf_rx_bytes;
  813. u64 vf_tx_packets;
  814. u64 vf_tx_bytes;
  815. };
  816. struct netvsc_vf_pcpu_stats {
  817. u64 rx_packets;
  818. u64 rx_bytes;
  819. u64 tx_packets;
  820. u64 tx_bytes;
  821. struct u64_stats_sync syncp;
  822. u32 tx_dropped;
  823. };
  824. struct netvsc_reconfig {
  825. struct list_head list;
  826. u32 event;
  827. };
  828. /* L4 hash bits for different protocols */
  829. #define HV_TCP4_L4HASH 1
  830. #define HV_TCP6_L4HASH 2
  831. #define HV_UDP4_L4HASH 4
  832. #define HV_UDP6_L4HASH 8
  833. #define HV_DEFAULT_L4HASH (HV_TCP4_L4HASH | HV_TCP6_L4HASH | HV_UDP4_L4HASH | \
  834. HV_UDP6_L4HASH)
  835. /* The context of the netvsc device */
  836. struct net_device_context {
  837. /* point back to our device context */
  838. struct hv_device *device_ctx;
  839. /* netvsc_device */
  840. struct netvsc_device __rcu *nvdev;
  841. /* list of netvsc net_devices */
  842. struct list_head list;
  843. /* reconfigure work */
  844. struct delayed_work dwork;
  845. /* last reconfig time */
  846. unsigned long last_reconfig;
  847. /* reconfig events */
  848. struct list_head reconfig_events;
  849. /* list protection */
  850. spinlock_t lock;
  851. u32 msg_enable; /* debug level */
  852. u32 tx_checksum_mask;
  853. u32 tx_table[VRSS_SEND_TAB_SIZE];
  854. u16 rx_table[ITAB_NUM];
  855. /* Ethtool settings */
  856. u8 duplex;
  857. u32 speed;
  858. u32 l4_hash; /* L4 hash settings */
  859. struct netvsc_ethtool_stats eth_stats;
  860. /* State to manage the associated VF interface. */
  861. struct net_device __rcu *vf_netdev;
  862. struct netvsc_vf_pcpu_stats __percpu *vf_stats;
  863. struct delayed_work vf_takeover;
  864. /* 1: allocated, serial number is valid. 0: not allocated */
  865. u32 vf_alloc;
  866. /* Serial number of the VF to team with */
  867. u32 vf_serial;
  868. /* completion variable to confirm vf association */
  869. struct completion vf_add;
  870. /* Is the current data path through the VF NIC? */
  871. bool data_path_is_vf;
  872. /* Used to temporarily save the config info across hibernation */
  873. struct netvsc_device_info *saved_netvsc_dev_info;
  874. };
  875. /* Azure hosts don't support non-TCP port numbers in hashing for fragmented
  876. * packets. We can use ethtool to change UDP hash level when necessary.
  877. */
  878. static inline u32 netvsc_get_hash(struct sk_buff *skb,
  879. const struct net_device_context *ndc)
  880. {
  881. struct flow_keys flow;
  882. u32 hash, pkt_proto = 0;
  883. static u32 hashrnd __read_mostly;
  884. net_get_random_once(&hashrnd, sizeof(hashrnd));
  885. if (!skb_flow_dissect_flow_keys(skb, &flow, 0))
  886. return 0;
  887. switch (flow.basic.ip_proto) {
  888. case IPPROTO_TCP:
  889. if (flow.basic.n_proto == htons(ETH_P_IP))
  890. pkt_proto = HV_TCP4_L4HASH;
  891. else if (flow.basic.n_proto == htons(ETH_P_IPV6))
  892. pkt_proto = HV_TCP6_L4HASH;
  893. break;
  894. case IPPROTO_UDP:
  895. if (flow.basic.n_proto == htons(ETH_P_IP))
  896. pkt_proto = HV_UDP4_L4HASH;
  897. else if (flow.basic.n_proto == htons(ETH_P_IPV6))
  898. pkt_proto = HV_UDP6_L4HASH;
  899. break;
  900. }
  901. if (pkt_proto & ndc->l4_hash) {
  902. return skb_get_hash(skb);
  903. } else {
  904. if (flow.basic.n_proto == htons(ETH_P_IP))
  905. hash = jhash2((u32 *)&flow.addrs.v4addrs, 2, hashrnd);
  906. else if (flow.basic.n_proto == htons(ETH_P_IPV6))
  907. hash = jhash2((u32 *)&flow.addrs.v6addrs, 8, hashrnd);
  908. else
  909. return 0;
  910. __skb_set_sw_hash(skb, hash, false);
  911. }
  912. return hash;
  913. }
  914. /* Per channel data */
  915. struct netvsc_channel {
  916. struct vmbus_channel *channel;
  917. struct netvsc_device *net_device;
  918. void *recv_buf; /* buffer to copy packets out from the receive buffer */
  919. const struct vmpacket_descriptor *desc;
  920. struct napi_struct napi;
  921. struct multi_send_data msd;
  922. struct multi_recv_comp mrc;
  923. atomic_t queue_sends;
  924. struct nvsc_rsc rsc;
  925. struct bpf_prog __rcu *bpf_prog;
  926. struct xdp_rxq_info xdp_rxq;
  927. bool xdp_flush;
  928. struct netvsc_stats_tx tx_stats;
  929. struct netvsc_stats_rx rx_stats;
  930. };
  931. /* Per netvsc device */
  932. struct netvsc_device {
  933. u32 nvsp_version;
  934. wait_queue_head_t wait_drain;
  935. bool destroy;
  936. bool tx_disable; /* if true, do not wake up queue again */
  937. /* Receive buffer allocated by us but manages by NetVSP */
  938. void *recv_buf;
  939. void *recv_original_buf;
  940. u32 recv_buf_size; /* allocated bytes */
  941. struct vmbus_gpadl recv_buf_gpadl_handle;
  942. u32 recv_section_cnt;
  943. u32 recv_section_size;
  944. u32 recv_completion_cnt;
  945. /* Send buffer allocated by us */
  946. void *send_buf;
  947. void *send_original_buf;
  948. u32 send_buf_size;
  949. struct vmbus_gpadl send_buf_gpadl_handle;
  950. u32 send_section_cnt;
  951. u32 send_section_size;
  952. unsigned long *send_section_map;
  953. /* Used for NetVSP initialization protocol */
  954. struct completion channel_init_wait;
  955. struct nvsp_message channel_init_pkt;
  956. struct nvsp_message revoke_packet;
  957. u32 max_chn;
  958. u32 num_chn;
  959. atomic_t open_chn;
  960. struct work_struct subchan_work;
  961. wait_queue_head_t subchan_open;
  962. struct rndis_device *extension;
  963. u32 max_pkt; /* max number of pkt in one send, e.g. 8 */
  964. u32 pkt_align; /* alignment bytes, e.g. 8 */
  965. struct netvsc_channel chan_table[VRSS_CHANNEL_MAX];
  966. struct rcu_head rcu;
  967. };
  968. /* NdisInitialize message */
  969. struct rndis_initialize_request {
  970. u32 req_id;
  971. u32 major_ver;
  972. u32 minor_ver;
  973. u32 max_xfer_size;
  974. };
  975. /* Response to NdisInitialize */
  976. struct rndis_initialize_complete {
  977. u32 req_id;
  978. u32 status;
  979. u32 major_ver;
  980. u32 minor_ver;
  981. u32 dev_flags;
  982. u32 medium;
  983. u32 max_pkt_per_msg;
  984. u32 max_xfer_size;
  985. u32 pkt_alignment_factor;
  986. u32 af_list_offset;
  987. u32 af_list_size;
  988. };
  989. /* Call manager devices only: Information about an address family */
  990. /* supported by the device is appended to the response to NdisInitialize. */
  991. struct rndis_co_address_family {
  992. u32 address_family;
  993. u32 major_ver;
  994. u32 minor_ver;
  995. };
  996. /* NdisHalt message */
  997. struct rndis_halt_request {
  998. u32 req_id;
  999. };
  1000. /* NdisQueryRequest message */
  1001. struct rndis_query_request {
  1002. u32 req_id;
  1003. u32 oid;
  1004. u32 info_buflen;
  1005. u32 info_buf_offset;
  1006. u32 dev_vc_handle;
  1007. };
  1008. /* Response to NdisQueryRequest */
  1009. struct rndis_query_complete {
  1010. u32 req_id;
  1011. u32 status;
  1012. u32 info_buflen;
  1013. u32 info_buf_offset;
  1014. };
  1015. /* NdisSetRequest message */
  1016. struct rndis_set_request {
  1017. u32 req_id;
  1018. u32 oid;
  1019. u32 info_buflen;
  1020. u32 info_buf_offset;
  1021. u32 dev_vc_handle;
  1022. u8 info_buf[];
  1023. };
  1024. /* Response to NdisSetRequest */
  1025. struct rndis_set_complete {
  1026. u32 req_id;
  1027. u32 status;
  1028. };
  1029. /* NdisReset message */
  1030. struct rndis_reset_request {
  1031. u32 reserved;
  1032. };
  1033. /* Response to NdisReset */
  1034. struct rndis_reset_complete {
  1035. u32 status;
  1036. u32 addressing_reset;
  1037. };
  1038. /* NdisMIndicateStatus message */
  1039. struct rndis_indicate_status {
  1040. u32 status;
  1041. u32 status_buflen;
  1042. u32 status_buf_offset;
  1043. };
  1044. /* Diagnostic information passed as the status buffer in */
  1045. /* struct rndis_indicate_status messages signifying error conditions. */
  1046. struct rndis_diagnostic_info {
  1047. u32 diag_status;
  1048. u32 error_offset;
  1049. };
  1050. /* NdisKeepAlive message */
  1051. struct rndis_keepalive_request {
  1052. u32 req_id;
  1053. };
  1054. /* Response to NdisKeepAlive */
  1055. struct rndis_keepalive_complete {
  1056. u32 req_id;
  1057. u32 status;
  1058. };
  1059. /*
  1060. * Data message. All Offset fields contain byte offsets from the beginning of
  1061. * struct rndis_packet. All Length fields are in bytes. VcHandle is set
  1062. * to 0 for connectionless data, otherwise it contains the VC handle.
  1063. */
  1064. struct rndis_packet {
  1065. u32 data_offset;
  1066. u32 data_len;
  1067. u32 oob_data_offset;
  1068. u32 oob_data_len;
  1069. u32 num_oob_data_elements;
  1070. u32 per_pkt_info_offset;
  1071. u32 per_pkt_info_len;
  1072. u32 vc_handle;
  1073. u32 reserved;
  1074. };
  1075. /* Optional Out of Band data associated with a Data message. */
  1076. struct rndis_oobd {
  1077. u32 size;
  1078. u32 type;
  1079. u32 class_info_offset;
  1080. };
  1081. /* Packet extension field contents associated with a Data message. */
  1082. struct rndis_per_packet_info {
  1083. u32 size;
  1084. u32 type:31;
  1085. u32 internal:1;
  1086. u32 ppi_offset;
  1087. };
  1088. enum ndis_per_pkt_info_type {
  1089. TCPIP_CHKSUM_PKTINFO,
  1090. IPSEC_PKTINFO,
  1091. TCP_LARGESEND_PKTINFO,
  1092. CLASSIFICATION_HANDLE_PKTINFO,
  1093. NDIS_RESERVED,
  1094. SG_LIST_PKTINFO,
  1095. IEEE_8021Q_INFO,
  1096. ORIGINAL_PKTINFO,
  1097. PACKET_CANCEL_ID,
  1098. NBL_HASH_VALUE = PACKET_CANCEL_ID,
  1099. ORIGINAL_NET_BUFLIST,
  1100. CACHED_NET_BUFLIST,
  1101. SHORT_PKT_PADINFO,
  1102. MAX_PER_PKT_INFO
  1103. };
  1104. enum rndis_per_pkt_info_interal_type {
  1105. RNDIS_PKTINFO_ID = 1,
  1106. /* Add more members here */
  1107. RNDIS_PKTINFO_MAX
  1108. };
  1109. #define RNDIS_PKTINFO_SUBALLOC BIT(0)
  1110. #define RNDIS_PKTINFO_1ST_FRAG BIT(1)
  1111. #define RNDIS_PKTINFO_LAST_FRAG BIT(2)
  1112. #define RNDIS_PKTINFO_ID_V1 1
  1113. struct rndis_pktinfo_id {
  1114. u8 ver;
  1115. u8 flag;
  1116. u16 pkt_id;
  1117. };
  1118. struct ndis_object_header {
  1119. u8 type;
  1120. u8 revision;
  1121. u16 size;
  1122. };
  1123. #define NDIS_OBJECT_TYPE_DEFAULT 0x80
  1124. #define NDIS_OFFLOAD_PARAMETERS_REVISION_3 3
  1125. #define NDIS_OFFLOAD_PARAMETERS_REVISION_2 2
  1126. #define NDIS_OFFLOAD_PARAMETERS_REVISION_1 1
  1127. #define NDIS_OFFLOAD_PARAMETERS_NO_CHANGE 0
  1128. #define NDIS_OFFLOAD_PARAMETERS_LSOV2_DISABLED 1
  1129. #define NDIS_OFFLOAD_PARAMETERS_LSOV2_ENABLED 2
  1130. #define NDIS_OFFLOAD_PARAMETERS_LSOV1_ENABLED 2
  1131. #define NDIS_OFFLOAD_PARAMETERS_RSC_DISABLED 1
  1132. #define NDIS_OFFLOAD_PARAMETERS_RSC_ENABLED 2
  1133. #define NDIS_OFFLOAD_PARAMETERS_TX_RX_DISABLED 1
  1134. #define NDIS_OFFLOAD_PARAMETERS_TX_ENABLED_RX_DISABLED 2
  1135. #define NDIS_OFFLOAD_PARAMETERS_RX_ENABLED_TX_DISABLED 3
  1136. #define NDIS_OFFLOAD_PARAMETERS_TX_RX_ENABLED 4
  1137. #define NDIS_TCP_LARGE_SEND_OFFLOAD_V2_TYPE 1
  1138. #define NDIS_TCP_LARGE_SEND_OFFLOAD_IPV4 0
  1139. #define NDIS_TCP_LARGE_SEND_OFFLOAD_IPV6 1
  1140. #define VERSION_4_OFFLOAD_SIZE 22
  1141. /*
  1142. * New offload OIDs for NDIS 6
  1143. */
  1144. #define OID_TCP_OFFLOAD_CURRENT_CONFIG 0xFC01020B /* query only */
  1145. #define OID_TCP_OFFLOAD_PARAMETERS 0xFC01020C /* set only */
  1146. #define OID_TCP_OFFLOAD_HARDWARE_CAPABILITIES 0xFC01020D/* query only */
  1147. #define OID_TCP_CONNECTION_OFFLOAD_CURRENT_CONFIG 0xFC01020E /* query only */
  1148. #define OID_TCP_CONNECTION_OFFLOAD_HARDWARE_CAPABILITIES 0xFC01020F /* query */
  1149. #define OID_OFFLOAD_ENCAPSULATION 0x0101010A /* set/query */
  1150. /*
  1151. * OID_TCP_OFFLOAD_HARDWARE_CAPABILITIES
  1152. * ndis_type: NDIS_OBJTYPE_OFFLOAD
  1153. */
  1154. #define NDIS_OFFLOAD_ENCAP_NONE 0x0000
  1155. #define NDIS_OFFLOAD_ENCAP_NULL 0x0001
  1156. #define NDIS_OFFLOAD_ENCAP_8023 0x0002
  1157. #define NDIS_OFFLOAD_ENCAP_8023PQ 0x0004
  1158. #define NDIS_OFFLOAD_ENCAP_8023PQ_OOB 0x0008
  1159. #define NDIS_OFFLOAD_ENCAP_RFC1483 0x0010
  1160. struct ndis_csum_offload {
  1161. u32 ip4_txenc;
  1162. u32 ip4_txcsum;
  1163. #define NDIS_TXCSUM_CAP_IP4OPT 0x001
  1164. #define NDIS_TXCSUM_CAP_TCP4OPT 0x004
  1165. #define NDIS_TXCSUM_CAP_TCP4 0x010
  1166. #define NDIS_TXCSUM_CAP_UDP4 0x040
  1167. #define NDIS_TXCSUM_CAP_IP4 0x100
  1168. #define NDIS_TXCSUM_ALL_TCP4 (NDIS_TXCSUM_CAP_TCP4 | NDIS_TXCSUM_CAP_TCP4OPT)
  1169. u32 ip4_rxenc;
  1170. u32 ip4_rxcsum;
  1171. #define NDIS_RXCSUM_CAP_IP4OPT 0x001
  1172. #define NDIS_RXCSUM_CAP_TCP4OPT 0x004
  1173. #define NDIS_RXCSUM_CAP_TCP4 0x010
  1174. #define NDIS_RXCSUM_CAP_UDP4 0x040
  1175. #define NDIS_RXCSUM_CAP_IP4 0x100
  1176. u32 ip6_txenc;
  1177. u32 ip6_txcsum;
  1178. #define NDIS_TXCSUM_CAP_IP6EXT 0x001
  1179. #define NDIS_TXCSUM_CAP_TCP6OPT 0x004
  1180. #define NDIS_TXCSUM_CAP_TCP6 0x010
  1181. #define NDIS_TXCSUM_CAP_UDP6 0x040
  1182. u32 ip6_rxenc;
  1183. u32 ip6_rxcsum;
  1184. #define NDIS_RXCSUM_CAP_IP6EXT 0x001
  1185. #define NDIS_RXCSUM_CAP_TCP6OPT 0x004
  1186. #define NDIS_RXCSUM_CAP_TCP6 0x010
  1187. #define NDIS_RXCSUM_CAP_UDP6 0x040
  1188. #define NDIS_TXCSUM_ALL_TCP6 (NDIS_TXCSUM_CAP_TCP6 | \
  1189. NDIS_TXCSUM_CAP_TCP6OPT | \
  1190. NDIS_TXCSUM_CAP_IP6EXT)
  1191. };
  1192. struct ndis_lsov1_offload {
  1193. u32 encap;
  1194. u32 maxsize;
  1195. u32 minsegs;
  1196. u32 opts;
  1197. };
  1198. struct ndis_ipsecv1_offload {
  1199. u32 encap;
  1200. u32 ah_esp;
  1201. u32 xport_tun;
  1202. u32 ip4_opts;
  1203. u32 flags;
  1204. u32 ip4_ah;
  1205. u32 ip4_esp;
  1206. };
  1207. struct ndis_lsov2_offload {
  1208. u32 ip4_encap;
  1209. u32 ip4_maxsz;
  1210. u32 ip4_minsg;
  1211. u32 ip6_encap;
  1212. u32 ip6_maxsz;
  1213. u32 ip6_minsg;
  1214. u32 ip6_opts;
  1215. #define NDIS_LSOV2_CAP_IP6EXT 0x001
  1216. #define NDIS_LSOV2_CAP_TCP6OPT 0x004
  1217. #define NDIS_LSOV2_CAP_IP6 (NDIS_LSOV2_CAP_IP6EXT | \
  1218. NDIS_LSOV2_CAP_TCP6OPT)
  1219. };
  1220. struct ndis_ipsecv2_offload {
  1221. u32 encap;
  1222. u8 ip6;
  1223. u8 ip4opt;
  1224. u8 ip6ext;
  1225. u8 ah;
  1226. u8 esp;
  1227. u8 ah_esp;
  1228. u8 xport;
  1229. u8 tun;
  1230. u8 xport_tun;
  1231. u8 lso;
  1232. u8 extseq;
  1233. u32 udp_esp;
  1234. u32 auth;
  1235. u32 crypto;
  1236. u32 sa_caps;
  1237. };
  1238. struct ndis_rsc_offload {
  1239. u8 ip4;
  1240. u8 ip6;
  1241. };
  1242. struct ndis_encap_offload {
  1243. u32 flags;
  1244. u32 maxhdr;
  1245. };
  1246. struct ndis_offload {
  1247. struct ndis_object_header header;
  1248. struct ndis_csum_offload csum;
  1249. struct ndis_lsov1_offload lsov1;
  1250. struct ndis_ipsecv1_offload ipsecv1;
  1251. struct ndis_lsov2_offload lsov2;
  1252. u32 flags;
  1253. /* NDIS >= 6.1 */
  1254. struct ndis_ipsecv2_offload ipsecv2;
  1255. /* NDIS >= 6.30 */
  1256. struct ndis_rsc_offload rsc;
  1257. struct ndis_encap_offload encap_gre;
  1258. };
  1259. #define NDIS_OFFLOAD_SIZE sizeof(struct ndis_offload)
  1260. #define NDIS_OFFLOAD_SIZE_6_0 offsetof(struct ndis_offload, ipsecv2)
  1261. #define NDIS_OFFLOAD_SIZE_6_1 offsetof(struct ndis_offload, rsc)
  1262. struct ndis_offload_params {
  1263. struct ndis_object_header header;
  1264. u8 ip_v4_csum;
  1265. u8 tcp_ip_v4_csum;
  1266. u8 udp_ip_v4_csum;
  1267. u8 tcp_ip_v6_csum;
  1268. u8 udp_ip_v6_csum;
  1269. u8 lso_v1;
  1270. u8 ip_sec_v1;
  1271. u8 lso_v2_ipv4;
  1272. u8 lso_v2_ipv6;
  1273. u8 tcp_connection_ip_v4;
  1274. u8 tcp_connection_ip_v6;
  1275. u32 flags;
  1276. u8 ip_sec_v2;
  1277. u8 ip_sec_v2_ip_v4;
  1278. struct {
  1279. u8 rsc_ip_v4;
  1280. u8 rsc_ip_v6;
  1281. };
  1282. struct {
  1283. u8 encapsulated_packet_task_offload;
  1284. u8 encapsulation_types;
  1285. };
  1286. };
  1287. struct ndis_tcp_lso_info {
  1288. union {
  1289. struct {
  1290. u32 unused:30;
  1291. u32 type:1;
  1292. u32 reserved2:1;
  1293. } transmit;
  1294. struct {
  1295. u32 mss:20;
  1296. u32 tcp_header_offset:10;
  1297. u32 type:1;
  1298. u32 reserved2:1;
  1299. } lso_v1_transmit;
  1300. struct {
  1301. u32 tcp_payload:30;
  1302. u32 type:1;
  1303. u32 reserved2:1;
  1304. } lso_v1_transmit_complete;
  1305. struct {
  1306. u32 mss:20;
  1307. u32 tcp_header_offset:10;
  1308. u32 type:1;
  1309. u32 ip_version:1;
  1310. } lso_v2_transmit;
  1311. struct {
  1312. u32 reserved:30;
  1313. u32 type:1;
  1314. u32 reserved2:1;
  1315. } lso_v2_transmit_complete;
  1316. u32 value;
  1317. };
  1318. };
  1319. #define NDIS_VLAN_PPI_SIZE (sizeof(struct rndis_per_packet_info) + \
  1320. sizeof(struct ndis_pkt_8021q_info))
  1321. #define NDIS_CSUM_PPI_SIZE (sizeof(struct rndis_per_packet_info) + \
  1322. sizeof(struct ndis_tcp_ip_checksum_info))
  1323. #define NDIS_LSO_PPI_SIZE (sizeof(struct rndis_per_packet_info) + \
  1324. sizeof(struct ndis_tcp_lso_info))
  1325. #define NDIS_HASH_PPI_SIZE (sizeof(struct rndis_per_packet_info) + \
  1326. sizeof(u32))
  1327. /* Total size of all PPI data */
  1328. #define NDIS_ALL_PPI_SIZE (NDIS_VLAN_PPI_SIZE + NDIS_CSUM_PPI_SIZE + \
  1329. NDIS_LSO_PPI_SIZE + NDIS_HASH_PPI_SIZE)
  1330. /* Format of Information buffer passed in a SetRequest for the OID */
  1331. /* OID_GEN_RNDIS_CONFIG_PARAMETER. */
  1332. struct rndis_config_parameter_info {
  1333. u32 parameter_name_offset;
  1334. u32 parameter_name_length;
  1335. u32 parameter_type;
  1336. u32 parameter_value_offset;
  1337. u32 parameter_value_length;
  1338. };
  1339. /* Values for ParameterType in struct rndis_config_parameter_info */
  1340. #define RNDIS_CONFIG_PARAM_TYPE_INTEGER 0
  1341. #define RNDIS_CONFIG_PARAM_TYPE_STRING 2
  1342. /* CONDIS Miniport messages for connection oriented devices */
  1343. /* that do not implement a call manager. */
  1344. /* CoNdisMiniportCreateVc message */
  1345. struct rcondis_mp_create_vc {
  1346. u32 req_id;
  1347. u32 ndis_vc_handle;
  1348. };
  1349. /* Response to CoNdisMiniportCreateVc */
  1350. struct rcondis_mp_create_vc_complete {
  1351. u32 req_id;
  1352. u32 dev_vc_handle;
  1353. u32 status;
  1354. };
  1355. /* CoNdisMiniportDeleteVc message */
  1356. struct rcondis_mp_delete_vc {
  1357. u32 req_id;
  1358. u32 dev_vc_handle;
  1359. };
  1360. /* Response to CoNdisMiniportDeleteVc */
  1361. struct rcondis_mp_delete_vc_complete {
  1362. u32 req_id;
  1363. u32 status;
  1364. };
  1365. /* CoNdisMiniportQueryRequest message */
  1366. struct rcondis_mp_query_request {
  1367. u32 req_id;
  1368. u32 request_type;
  1369. u32 oid;
  1370. u32 dev_vc_handle;
  1371. u32 info_buflen;
  1372. u32 info_buf_offset;
  1373. };
  1374. /* CoNdisMiniportSetRequest message */
  1375. struct rcondis_mp_set_request {
  1376. u32 req_id;
  1377. u32 request_type;
  1378. u32 oid;
  1379. u32 dev_vc_handle;
  1380. u32 info_buflen;
  1381. u32 info_buf_offset;
  1382. };
  1383. /* CoNdisIndicateStatus message */
  1384. struct rcondis_indicate_status {
  1385. u32 ndis_vc_handle;
  1386. u32 status;
  1387. u32 status_buflen;
  1388. u32 status_buf_offset;
  1389. };
  1390. /* CONDIS Call/VC parameters */
  1391. struct rcondis_specific_parameters {
  1392. u32 parameter_type;
  1393. u32 parameter_length;
  1394. u32 parameter_lffset;
  1395. };
  1396. struct rcondis_media_parameters {
  1397. u32 flags;
  1398. u32 reserved1;
  1399. u32 reserved2;
  1400. struct rcondis_specific_parameters media_specific;
  1401. };
  1402. struct rndis_flowspec {
  1403. u32 token_rate;
  1404. u32 token_bucket_size;
  1405. u32 peak_bandwidth;
  1406. u32 latency;
  1407. u32 delay_variation;
  1408. u32 service_type;
  1409. u32 max_sdu_size;
  1410. u32 minimum_policed_size;
  1411. };
  1412. struct rcondis_call_manager_parameters {
  1413. struct rndis_flowspec transmit;
  1414. struct rndis_flowspec receive;
  1415. struct rcondis_specific_parameters call_mgr_specific;
  1416. };
  1417. /* CoNdisMiniportActivateVc message */
  1418. struct rcondis_mp_activate_vc_request {
  1419. u32 req_id;
  1420. u32 flags;
  1421. u32 dev_vc_handle;
  1422. u32 media_params_offset;
  1423. u32 media_params_length;
  1424. u32 call_mgr_params_offset;
  1425. u32 call_mgr_params_length;
  1426. };
  1427. /* Response to CoNdisMiniportActivateVc */
  1428. struct rcondis_mp_activate_vc_complete {
  1429. u32 req_id;
  1430. u32 status;
  1431. };
  1432. /* CoNdisMiniportDeactivateVc message */
  1433. struct rcondis_mp_deactivate_vc_request {
  1434. u32 req_id;
  1435. u32 flags;
  1436. u32 dev_vc_handle;
  1437. };
  1438. /* Response to CoNdisMiniportDeactivateVc */
  1439. struct rcondis_mp_deactivate_vc_complete {
  1440. u32 req_id;
  1441. u32 status;
  1442. };
  1443. /* union with all of the RNDIS messages */
  1444. union rndis_message_container {
  1445. struct rndis_packet pkt;
  1446. struct rndis_initialize_request init_req;
  1447. struct rndis_halt_request halt_req;
  1448. struct rndis_query_request query_req;
  1449. struct rndis_set_request set_req;
  1450. struct rndis_reset_request reset_req;
  1451. struct rndis_keepalive_request keep_alive_req;
  1452. struct rndis_indicate_status indicate_status;
  1453. struct rndis_initialize_complete init_complete;
  1454. struct rndis_query_complete query_complete;
  1455. struct rndis_set_complete set_complete;
  1456. struct rndis_reset_complete reset_complete;
  1457. struct rndis_keepalive_complete keep_alive_complete;
  1458. struct rcondis_mp_create_vc co_miniport_create_vc;
  1459. struct rcondis_mp_delete_vc co_miniport_delete_vc;
  1460. struct rcondis_indicate_status co_indicate_status;
  1461. struct rcondis_mp_activate_vc_request co_miniport_activate_vc;
  1462. struct rcondis_mp_deactivate_vc_request co_miniport_deactivate_vc;
  1463. struct rcondis_mp_create_vc_complete co_miniport_create_vc_complete;
  1464. struct rcondis_mp_delete_vc_complete co_miniport_delete_vc_complete;
  1465. struct rcondis_mp_activate_vc_complete co_miniport_activate_vc_complete;
  1466. struct rcondis_mp_deactivate_vc_complete
  1467. co_miniport_deactivate_vc_complete;
  1468. };
  1469. /* Remote NDIS message format */
  1470. struct rndis_message {
  1471. u32 ndis_msg_type;
  1472. /* Total length of this message, from the beginning */
  1473. /* of the struct rndis_message, in bytes. */
  1474. u32 msg_len;
  1475. /* Actual message */
  1476. union rndis_message_container msg;
  1477. };
  1478. /* Handy macros */
  1479. /* get the size of an RNDIS message. Pass in the message type, */
  1480. /* struct rndis_set_request, struct rndis_packet for example */
  1481. #define RNDIS_MESSAGE_SIZE(msg) \
  1482. (sizeof(msg) + (sizeof(struct rndis_message) - \
  1483. sizeof(union rndis_message_container)))
  1484. #define RNDIS_HEADER_SIZE (sizeof(struct rndis_message) - \
  1485. sizeof(union rndis_message_container))
  1486. #define RNDIS_AND_PPI_SIZE (sizeof(struct rndis_message) + NDIS_ALL_PPI_SIZE)
  1487. #define NDIS_PACKET_TYPE_DIRECTED 0x00000001
  1488. #define NDIS_PACKET_TYPE_MULTICAST 0x00000002
  1489. #define NDIS_PACKET_TYPE_ALL_MULTICAST 0x00000004
  1490. #define NDIS_PACKET_TYPE_BROADCAST 0x00000008
  1491. #define NDIS_PACKET_TYPE_SOURCE_ROUTING 0x00000010
  1492. #define NDIS_PACKET_TYPE_PROMISCUOUS 0x00000020
  1493. #define NDIS_PACKET_TYPE_SMT 0x00000040
  1494. #define NDIS_PACKET_TYPE_ALL_LOCAL 0x00000080
  1495. #define NDIS_PACKET_TYPE_GROUP 0x00000100
  1496. #define NDIS_PACKET_TYPE_ALL_FUNCTIONAL 0x00000200
  1497. #define NDIS_PACKET_TYPE_FUNCTIONAL 0x00000400
  1498. #define NDIS_PACKET_TYPE_MAC_FRAME 0x00000800
  1499. #define TRANSPORT_INFO_NOT_IP 0
  1500. #define TRANSPORT_INFO_IPV4_TCP 0x01
  1501. #define TRANSPORT_INFO_IPV4_UDP 0x02
  1502. #define TRANSPORT_INFO_IPV6_TCP 0x10
  1503. #define TRANSPORT_INFO_IPV6_UDP 0x20
  1504. #define RETRY_US_LO 5000
  1505. #define RETRY_US_HI 10000
  1506. #define RETRY_MAX 2000 /* >10 sec */
  1507. void netvsc_dma_unmap(struct hv_device *hv_dev,
  1508. struct hv_netvsc_packet *packet);
  1509. #endif /* _HYPERV_NET_H */