netvsc_drv.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250
  1. /*
  2. * Copyright (c) 2009, Microsoft Corporation.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms and conditions of the GNU General Public License,
  6. * version 2, as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope it will be useful, but WITHOUT
  9. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. * more details.
  12. *
  13. * You should have received a copy of the GNU General Public License along with
  14. * this program; if not, see <http://www.gnu.org/licenses/>.
  15. *
  16. * Authors:
  17. * Haiyang Zhang <haiyangz@microsoft.com>
  18. * Hank Janssen <hjanssen@microsoft.com>
  19. */
  20. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  21. #include <linux/init.h>
  22. #include <linux/atomic.h>
  23. #include <linux/module.h>
  24. #include <linux/highmem.h>
  25. #include <linux/device.h>
  26. #include <linux/io.h>
  27. #include <linux/delay.h>
  28. #include <linux/netdevice.h>
  29. #include <linux/inetdevice.h>
  30. #include <linux/etherdevice.h>
  31. #include <linux/skbuff.h>
  32. #include <linux/if_vlan.h>
  33. #include <linux/in.h>
  34. #include <linux/slab.h>
  35. #include <net/arp.h>
  36. #include <net/route.h>
  37. #include <net/sock.h>
  38. #include <net/pkt_sched.h>
  39. #include "hyperv_net.h"
  40. #define RING_SIZE_MIN 64
  41. #define LINKCHANGE_INT (2 * HZ)
  42. static int ring_size = 128;
  43. module_param(ring_size, int, S_IRUGO);
  44. MODULE_PARM_DESC(ring_size, "Ring buffer size (# of pages)");
  45. static int max_num_vrss_chns = 8;
  46. static const u32 default_msg = NETIF_MSG_DRV | NETIF_MSG_PROBE |
  47. NETIF_MSG_LINK | NETIF_MSG_IFUP |
  48. NETIF_MSG_IFDOWN | NETIF_MSG_RX_ERR |
  49. NETIF_MSG_TX_ERR;
  50. static int debug = -1;
  51. module_param(debug, int, S_IRUGO);
  52. MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
  53. static void do_set_multicast(struct work_struct *w)
  54. {
  55. struct net_device_context *ndevctx =
  56. container_of(w, struct net_device_context, work);
  57. struct netvsc_device *nvdev;
  58. struct rndis_device *rdev;
  59. nvdev = hv_get_drvdata(ndevctx->device_ctx);
  60. if (nvdev == NULL || nvdev->ndev == NULL)
  61. return;
  62. rdev = nvdev->extension;
  63. if (rdev == NULL)
  64. return;
  65. if (nvdev->ndev->flags & IFF_PROMISC)
  66. rndis_filter_set_packet_filter(rdev,
  67. NDIS_PACKET_TYPE_PROMISCUOUS);
  68. else
  69. rndis_filter_set_packet_filter(rdev,
  70. NDIS_PACKET_TYPE_BROADCAST |
  71. NDIS_PACKET_TYPE_ALL_MULTICAST |
  72. NDIS_PACKET_TYPE_DIRECTED);
  73. }
  74. static void netvsc_set_multicast_list(struct net_device *net)
  75. {
  76. struct net_device_context *net_device_ctx = netdev_priv(net);
  77. schedule_work(&net_device_ctx->work);
  78. }
  79. static int netvsc_open(struct net_device *net)
  80. {
  81. struct net_device_context *net_device_ctx = netdev_priv(net);
  82. struct hv_device *device_obj = net_device_ctx->device_ctx;
  83. struct netvsc_device *nvdev;
  84. struct rndis_device *rdev;
  85. int ret = 0;
  86. netif_carrier_off(net);
  87. /* Open up the device */
  88. ret = rndis_filter_open(device_obj);
  89. if (ret != 0) {
  90. netdev_err(net, "unable to open device (ret %d).\n", ret);
  91. return ret;
  92. }
  93. netif_tx_wake_all_queues(net);
  94. nvdev = hv_get_drvdata(device_obj);
  95. rdev = nvdev->extension;
  96. if (!rdev->link_state)
  97. netif_carrier_on(net);
  98. return ret;
  99. }
  100. static int netvsc_close(struct net_device *net)
  101. {
  102. struct net_device_context *net_device_ctx = netdev_priv(net);
  103. struct hv_device *device_obj = net_device_ctx->device_ctx;
  104. struct netvsc_device *nvdev = hv_get_drvdata(device_obj);
  105. int ret;
  106. u32 aread, awrite, i, msec = 10, retry = 0, retry_max = 20;
  107. struct vmbus_channel *chn;
  108. netif_tx_disable(net);
  109. /* Make sure netvsc_set_multicast_list doesn't re-enable filter! */
  110. cancel_work_sync(&net_device_ctx->work);
  111. ret = rndis_filter_close(device_obj);
  112. if (ret != 0) {
  113. netdev_err(net, "unable to close device (ret %d).\n", ret);
  114. return ret;
  115. }
  116. /* Ensure pending bytes in ring are read */
  117. while (true) {
  118. aread = 0;
  119. for (i = 0; i < nvdev->num_chn; i++) {
  120. chn = nvdev->chn_table[i];
  121. if (!chn)
  122. continue;
  123. hv_get_ringbuffer_availbytes(&chn->inbound, &aread,
  124. &awrite);
  125. if (aread)
  126. break;
  127. hv_get_ringbuffer_availbytes(&chn->outbound, &aread,
  128. &awrite);
  129. if (aread)
  130. break;
  131. }
  132. retry++;
  133. if (retry > retry_max || aread == 0)
  134. break;
  135. msleep(msec);
  136. if (msec < 1000)
  137. msec *= 2;
  138. }
  139. if (aread) {
  140. netdev_err(net, "Ring buffer not empty after closing rndis\n");
  141. ret = -ETIMEDOUT;
  142. }
  143. return ret;
  144. }
  145. static void *init_ppi_data(struct rndis_message *msg, u32 ppi_size,
  146. int pkt_type)
  147. {
  148. struct rndis_packet *rndis_pkt;
  149. struct rndis_per_packet_info *ppi;
  150. rndis_pkt = &msg->msg.pkt;
  151. rndis_pkt->data_offset += ppi_size;
  152. ppi = (struct rndis_per_packet_info *)((void *)rndis_pkt +
  153. rndis_pkt->per_pkt_info_offset + rndis_pkt->per_pkt_info_len);
  154. ppi->size = ppi_size;
  155. ppi->type = pkt_type;
  156. ppi->ppi_offset = sizeof(struct rndis_per_packet_info);
  157. rndis_pkt->per_pkt_info_len += ppi_size;
  158. return ppi;
  159. }
  160. union sub_key {
  161. u64 k;
  162. struct {
  163. u8 pad[3];
  164. u8 kb;
  165. u32 ka;
  166. };
  167. };
  168. /* Toeplitz hash function
  169. * data: network byte order
  170. * return: host byte order
  171. */
  172. static u32 comp_hash(u8 *key, int klen, void *data, int dlen)
  173. {
  174. union sub_key subk;
  175. int k_next = 4;
  176. u8 dt;
  177. int i, j;
  178. u32 ret = 0;
  179. subk.k = 0;
  180. subk.ka = ntohl(*(u32 *)key);
  181. for (i = 0; i < dlen; i++) {
  182. subk.kb = key[k_next];
  183. k_next = (k_next + 1) % klen;
  184. dt = ((u8 *)data)[i];
  185. for (j = 0; j < 8; j++) {
  186. if (dt & 0x80)
  187. ret ^= subk.ka;
  188. dt <<= 1;
  189. subk.k <<= 1;
  190. }
  191. }
  192. return ret;
  193. }
  194. static bool netvsc_set_hash(u32 *hash, struct sk_buff *skb)
  195. {
  196. struct flow_keys flow;
  197. int data_len;
  198. if (!skb_flow_dissect_flow_keys(skb, &flow, 0) ||
  199. !(flow.basic.n_proto == htons(ETH_P_IP) ||
  200. flow.basic.n_proto == htons(ETH_P_IPV6)))
  201. return false;
  202. if (flow.basic.ip_proto == IPPROTO_TCP)
  203. data_len = 12;
  204. else
  205. data_len = 8;
  206. *hash = comp_hash(netvsc_hash_key, HASH_KEYLEN, &flow, data_len);
  207. return true;
  208. }
  209. static u16 netvsc_select_queue(struct net_device *ndev, struct sk_buff *skb,
  210. void *accel_priv, select_queue_fallback_t fallback)
  211. {
  212. struct net_device_context *net_device_ctx = netdev_priv(ndev);
  213. struct hv_device *hdev = net_device_ctx->device_ctx;
  214. struct netvsc_device *nvsc_dev = hv_get_drvdata(hdev);
  215. u32 hash;
  216. u16 q_idx = 0;
  217. if (nvsc_dev == NULL || ndev->real_num_tx_queues <= 1)
  218. return 0;
  219. if (netvsc_set_hash(&hash, skb)) {
  220. q_idx = nvsc_dev->send_table[hash % VRSS_SEND_TAB_SIZE] %
  221. ndev->real_num_tx_queues;
  222. skb_set_hash(skb, hash, PKT_HASH_TYPE_L3);
  223. }
  224. if (!nvsc_dev->chn_table[q_idx])
  225. q_idx = 0;
  226. return q_idx;
  227. }
  228. static u32 fill_pg_buf(struct page *page, u32 offset, u32 len,
  229. struct hv_page_buffer *pb)
  230. {
  231. int j = 0;
  232. /* Deal with compund pages by ignoring unused part
  233. * of the page.
  234. */
  235. page += (offset >> PAGE_SHIFT);
  236. offset &= ~PAGE_MASK;
  237. while (len > 0) {
  238. unsigned long bytes;
  239. bytes = PAGE_SIZE - offset;
  240. if (bytes > len)
  241. bytes = len;
  242. pb[j].pfn = page_to_pfn(page);
  243. pb[j].offset = offset;
  244. pb[j].len = bytes;
  245. offset += bytes;
  246. len -= bytes;
  247. if (offset == PAGE_SIZE && len) {
  248. page++;
  249. offset = 0;
  250. j++;
  251. }
  252. }
  253. return j + 1;
  254. }
  255. static u32 init_page_array(void *hdr, u32 len, struct sk_buff *skb,
  256. struct hv_netvsc_packet *packet,
  257. struct hv_page_buffer **page_buf)
  258. {
  259. struct hv_page_buffer *pb = *page_buf;
  260. u32 slots_used = 0;
  261. char *data = skb->data;
  262. int frags = skb_shinfo(skb)->nr_frags;
  263. int i;
  264. /* The packet is laid out thus:
  265. * 1. hdr: RNDIS header and PPI
  266. * 2. skb linear data
  267. * 3. skb fragment data
  268. */
  269. if (hdr != NULL)
  270. slots_used += fill_pg_buf(virt_to_page(hdr),
  271. offset_in_page(hdr),
  272. len, &pb[slots_used]);
  273. packet->rmsg_size = len;
  274. packet->rmsg_pgcnt = slots_used;
  275. slots_used += fill_pg_buf(virt_to_page(data),
  276. offset_in_page(data),
  277. skb_headlen(skb), &pb[slots_used]);
  278. for (i = 0; i < frags; i++) {
  279. skb_frag_t *frag = skb_shinfo(skb)->frags + i;
  280. slots_used += fill_pg_buf(skb_frag_page(frag),
  281. frag->page_offset,
  282. skb_frag_size(frag), &pb[slots_used]);
  283. }
  284. return slots_used;
  285. }
  286. static int count_skb_frag_slots(struct sk_buff *skb)
  287. {
  288. int i, frags = skb_shinfo(skb)->nr_frags;
  289. int pages = 0;
  290. for (i = 0; i < frags; i++) {
  291. skb_frag_t *frag = skb_shinfo(skb)->frags + i;
  292. unsigned long size = skb_frag_size(frag);
  293. unsigned long offset = frag->page_offset;
  294. /* Skip unused frames from start of page */
  295. offset &= ~PAGE_MASK;
  296. pages += PFN_UP(offset + size);
  297. }
  298. return pages;
  299. }
  300. static int netvsc_get_slots(struct sk_buff *skb)
  301. {
  302. char *data = skb->data;
  303. unsigned int offset = offset_in_page(data);
  304. unsigned int len = skb_headlen(skb);
  305. int slots;
  306. int frag_slots;
  307. slots = DIV_ROUND_UP(offset + len, PAGE_SIZE);
  308. frag_slots = count_skb_frag_slots(skb);
  309. return slots + frag_slots;
  310. }
  311. static u32 get_net_transport_info(struct sk_buff *skb, u32 *trans_off)
  312. {
  313. u32 ret_val = TRANSPORT_INFO_NOT_IP;
  314. if ((eth_hdr(skb)->h_proto != htons(ETH_P_IP)) &&
  315. (eth_hdr(skb)->h_proto != htons(ETH_P_IPV6))) {
  316. goto not_ip;
  317. }
  318. *trans_off = skb_transport_offset(skb);
  319. if ((eth_hdr(skb)->h_proto == htons(ETH_P_IP))) {
  320. struct iphdr *iphdr = ip_hdr(skb);
  321. if (iphdr->protocol == IPPROTO_TCP)
  322. ret_val = TRANSPORT_INFO_IPV4_TCP;
  323. else if (iphdr->protocol == IPPROTO_UDP)
  324. ret_val = TRANSPORT_INFO_IPV4_UDP;
  325. } else {
  326. if (ipv6_hdr(skb)->nexthdr == IPPROTO_TCP)
  327. ret_val = TRANSPORT_INFO_IPV6_TCP;
  328. else if (ipv6_hdr(skb)->nexthdr == IPPROTO_UDP)
  329. ret_val = TRANSPORT_INFO_IPV6_UDP;
  330. }
  331. not_ip:
  332. return ret_val;
  333. }
  334. static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
  335. {
  336. struct net_device_context *net_device_ctx = netdev_priv(net);
  337. struct hv_netvsc_packet *packet = NULL;
  338. int ret;
  339. unsigned int num_data_pgs;
  340. struct rndis_message *rndis_msg;
  341. struct rndis_packet *rndis_pkt;
  342. u32 rndis_msg_size;
  343. bool isvlan;
  344. bool linear = false;
  345. struct rndis_per_packet_info *ppi;
  346. struct ndis_tcp_ip_checksum_info *csum_info;
  347. struct ndis_tcp_lso_info *lso_info;
  348. int hdr_offset;
  349. u32 net_trans_info;
  350. u32 hash;
  351. u32 skb_length;
  352. struct hv_page_buffer page_buf[MAX_PAGE_BUFFER_COUNT];
  353. struct hv_page_buffer *pb = page_buf;
  354. struct netvsc_stats *tx_stats = this_cpu_ptr(net_device_ctx->tx_stats);
  355. /* We will atmost need two pages to describe the rndis
  356. * header. We can only transmit MAX_PAGE_BUFFER_COUNT number
  357. * of pages in a single packet. If skb is scattered around
  358. * more pages we try linearizing it.
  359. */
  360. check_size:
  361. skb_length = skb->len;
  362. num_data_pgs = netvsc_get_slots(skb) + 2;
  363. if (num_data_pgs > MAX_PAGE_BUFFER_COUNT && linear) {
  364. net_alert_ratelimited("packet too big: %u pages (%u bytes)\n",
  365. num_data_pgs, skb->len);
  366. ret = -EFAULT;
  367. goto drop;
  368. } else if (num_data_pgs > MAX_PAGE_BUFFER_COUNT) {
  369. if (skb_linearize(skb)) {
  370. net_alert_ratelimited("failed to linearize skb\n");
  371. ret = -ENOMEM;
  372. goto drop;
  373. }
  374. linear = true;
  375. goto check_size;
  376. }
  377. /*
  378. * Place the rndis header in the skb head room and
  379. * the skb->cb will be used for hv_netvsc_packet
  380. * structure.
  381. */
  382. ret = skb_cow_head(skb, RNDIS_AND_PPI_SIZE);
  383. if (ret) {
  384. netdev_err(net, "unable to alloc hv_netvsc_packet\n");
  385. ret = -ENOMEM;
  386. goto drop;
  387. }
  388. /* Use the skb control buffer for building up the packet */
  389. BUILD_BUG_ON(sizeof(struct hv_netvsc_packet) >
  390. FIELD_SIZEOF(struct sk_buff, cb));
  391. packet = (struct hv_netvsc_packet *)skb->cb;
  392. packet->q_idx = skb_get_queue_mapping(skb);
  393. packet->total_data_buflen = skb->len;
  394. rndis_msg = (struct rndis_message *)skb->head;
  395. memset(rndis_msg, 0, RNDIS_AND_PPI_SIZE);
  396. isvlan = skb->vlan_tci & VLAN_TAG_PRESENT;
  397. /* Add the rndis header */
  398. rndis_msg->ndis_msg_type = RNDIS_MSG_PACKET;
  399. rndis_msg->msg_len = packet->total_data_buflen;
  400. rndis_pkt = &rndis_msg->msg.pkt;
  401. rndis_pkt->data_offset = sizeof(struct rndis_packet);
  402. rndis_pkt->data_len = packet->total_data_buflen;
  403. rndis_pkt->per_pkt_info_offset = sizeof(struct rndis_packet);
  404. rndis_msg_size = RNDIS_MESSAGE_SIZE(struct rndis_packet);
  405. hash = skb_get_hash_raw(skb);
  406. if (hash != 0 && net->real_num_tx_queues > 1) {
  407. rndis_msg_size += NDIS_HASH_PPI_SIZE;
  408. ppi = init_ppi_data(rndis_msg, NDIS_HASH_PPI_SIZE,
  409. NBL_HASH_VALUE);
  410. *(u32 *)((void *)ppi + ppi->ppi_offset) = hash;
  411. }
  412. if (isvlan) {
  413. struct ndis_pkt_8021q_info *vlan;
  414. rndis_msg_size += NDIS_VLAN_PPI_SIZE;
  415. ppi = init_ppi_data(rndis_msg, NDIS_VLAN_PPI_SIZE,
  416. IEEE_8021Q_INFO);
  417. vlan = (struct ndis_pkt_8021q_info *)((void *)ppi +
  418. ppi->ppi_offset);
  419. vlan->vlanid = skb->vlan_tci & VLAN_VID_MASK;
  420. vlan->pri = (skb->vlan_tci & VLAN_PRIO_MASK) >>
  421. VLAN_PRIO_SHIFT;
  422. }
  423. net_trans_info = get_net_transport_info(skb, &hdr_offset);
  424. if (net_trans_info == TRANSPORT_INFO_NOT_IP)
  425. goto do_send;
  426. /*
  427. * Setup the sendside checksum offload only if this is not a
  428. * GSO packet.
  429. */
  430. if (skb_is_gso(skb))
  431. goto do_lso;
  432. if ((skb->ip_summed == CHECKSUM_NONE) ||
  433. (skb->ip_summed == CHECKSUM_UNNECESSARY))
  434. goto do_send;
  435. rndis_msg_size += NDIS_CSUM_PPI_SIZE;
  436. ppi = init_ppi_data(rndis_msg, NDIS_CSUM_PPI_SIZE,
  437. TCPIP_CHKSUM_PKTINFO);
  438. csum_info = (struct ndis_tcp_ip_checksum_info *)((void *)ppi +
  439. ppi->ppi_offset);
  440. if (net_trans_info & (INFO_IPV4 << 16))
  441. csum_info->transmit.is_ipv4 = 1;
  442. else
  443. csum_info->transmit.is_ipv6 = 1;
  444. if (net_trans_info & INFO_TCP) {
  445. csum_info->transmit.tcp_checksum = 1;
  446. csum_info->transmit.tcp_header_offset = hdr_offset;
  447. } else if (net_trans_info & INFO_UDP) {
  448. /* UDP checksum offload is not supported on ws2008r2.
  449. * Furthermore, on ws2012 and ws2012r2, there are some
  450. * issues with udp checksum offload from Linux guests.
  451. * (these are host issues).
  452. * For now compute the checksum here.
  453. */
  454. struct udphdr *uh;
  455. u16 udp_len;
  456. ret = skb_cow_head(skb, 0);
  457. if (ret)
  458. goto drop;
  459. uh = udp_hdr(skb);
  460. udp_len = ntohs(uh->len);
  461. uh->check = 0;
  462. uh->check = csum_tcpudp_magic(ip_hdr(skb)->saddr,
  463. ip_hdr(skb)->daddr,
  464. udp_len, IPPROTO_UDP,
  465. csum_partial(uh, udp_len, 0));
  466. if (uh->check == 0)
  467. uh->check = CSUM_MANGLED_0;
  468. csum_info->transmit.udp_checksum = 0;
  469. }
  470. goto do_send;
  471. do_lso:
  472. rndis_msg_size += NDIS_LSO_PPI_SIZE;
  473. ppi = init_ppi_data(rndis_msg, NDIS_LSO_PPI_SIZE,
  474. TCP_LARGESEND_PKTINFO);
  475. lso_info = (struct ndis_tcp_lso_info *)((void *)ppi +
  476. ppi->ppi_offset);
  477. lso_info->lso_v2_transmit.type = NDIS_TCP_LARGE_SEND_OFFLOAD_V2_TYPE;
  478. if (net_trans_info & (INFO_IPV4 << 16)) {
  479. lso_info->lso_v2_transmit.ip_version =
  480. NDIS_TCP_LARGE_SEND_OFFLOAD_IPV4;
  481. ip_hdr(skb)->tot_len = 0;
  482. ip_hdr(skb)->check = 0;
  483. tcp_hdr(skb)->check =
  484. ~csum_tcpudp_magic(ip_hdr(skb)->saddr,
  485. ip_hdr(skb)->daddr, 0, IPPROTO_TCP, 0);
  486. } else {
  487. lso_info->lso_v2_transmit.ip_version =
  488. NDIS_TCP_LARGE_SEND_OFFLOAD_IPV6;
  489. ipv6_hdr(skb)->payload_len = 0;
  490. tcp_hdr(skb)->check =
  491. ~csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
  492. &ipv6_hdr(skb)->daddr, 0, IPPROTO_TCP, 0);
  493. }
  494. lso_info->lso_v2_transmit.tcp_header_offset = hdr_offset;
  495. lso_info->lso_v2_transmit.mss = skb_shinfo(skb)->gso_size;
  496. do_send:
  497. /* Start filling in the page buffers with the rndis hdr */
  498. rndis_msg->msg_len += rndis_msg_size;
  499. packet->total_data_buflen = rndis_msg->msg_len;
  500. packet->page_buf_cnt = init_page_array(rndis_msg, rndis_msg_size,
  501. skb, packet, &pb);
  502. ret = netvsc_send(net_device_ctx->device_ctx, packet,
  503. rndis_msg, &pb, skb);
  504. drop:
  505. if (ret == 0) {
  506. u64_stats_update_begin(&tx_stats->syncp);
  507. tx_stats->packets++;
  508. tx_stats->bytes += skb_length;
  509. u64_stats_update_end(&tx_stats->syncp);
  510. } else {
  511. if (ret != -EAGAIN) {
  512. dev_kfree_skb_any(skb);
  513. net->stats.tx_dropped++;
  514. }
  515. }
  516. return (ret == -EAGAIN) ? NETDEV_TX_BUSY : NETDEV_TX_OK;
  517. }
  518. /*
  519. * netvsc_linkstatus_callback - Link up/down notification
  520. */
  521. void netvsc_linkstatus_callback(struct hv_device *device_obj,
  522. struct rndis_message *resp)
  523. {
  524. struct rndis_indicate_status *indicate = &resp->msg.indicate_status;
  525. struct net_device *net;
  526. struct net_device_context *ndev_ctx;
  527. struct netvsc_device *net_device;
  528. struct netvsc_reconfig *event;
  529. unsigned long flags;
  530. /* Handle link change statuses only */
  531. if (indicate->status != RNDIS_STATUS_NETWORK_CHANGE &&
  532. indicate->status != RNDIS_STATUS_MEDIA_CONNECT &&
  533. indicate->status != RNDIS_STATUS_MEDIA_DISCONNECT)
  534. return;
  535. net_device = hv_get_drvdata(device_obj);
  536. net = net_device->ndev;
  537. if (!net || net->reg_state != NETREG_REGISTERED)
  538. return;
  539. ndev_ctx = netdev_priv(net);
  540. event = kzalloc(sizeof(*event), GFP_ATOMIC);
  541. if (!event)
  542. return;
  543. event->event = indicate->status;
  544. spin_lock_irqsave(&ndev_ctx->lock, flags);
  545. list_add_tail(&event->list, &ndev_ctx->reconfig_events);
  546. spin_unlock_irqrestore(&ndev_ctx->lock, flags);
  547. schedule_delayed_work(&ndev_ctx->dwork, 0);
  548. }
  549. /*
  550. * netvsc_recv_callback - Callback when we receive a packet from the
  551. * "wire" on the specified device.
  552. */
  553. int netvsc_recv_callback(struct hv_device *device_obj,
  554. struct hv_netvsc_packet *packet,
  555. void **data,
  556. struct ndis_tcp_ip_checksum_info *csum_info,
  557. struct vmbus_channel *channel,
  558. u16 vlan_tci)
  559. {
  560. struct net_device *net;
  561. struct net_device_context *net_device_ctx;
  562. struct sk_buff *skb;
  563. struct netvsc_stats *rx_stats;
  564. net = ((struct netvsc_device *)hv_get_drvdata(device_obj))->ndev;
  565. if (!net || net->reg_state != NETREG_REGISTERED) {
  566. return NVSP_STAT_FAIL;
  567. }
  568. net_device_ctx = netdev_priv(net);
  569. rx_stats = this_cpu_ptr(net_device_ctx->rx_stats);
  570. /* Allocate a skb - TODO direct I/O to pages? */
  571. skb = netdev_alloc_skb_ip_align(net, packet->total_data_buflen);
  572. if (unlikely(!skb)) {
  573. ++net->stats.rx_dropped;
  574. return NVSP_STAT_FAIL;
  575. }
  576. /*
  577. * Copy to skb. This copy is needed here since the memory pointed by
  578. * hv_netvsc_packet cannot be deallocated
  579. */
  580. memcpy(skb_put(skb, packet->total_data_buflen), *data,
  581. packet->total_data_buflen);
  582. skb->protocol = eth_type_trans(skb, net);
  583. if (csum_info) {
  584. /* We only look at the IP checksum here.
  585. * Should we be dropping the packet if checksum
  586. * failed? How do we deal with other checksums - TCP/UDP?
  587. */
  588. if (csum_info->receive.ip_checksum_succeeded)
  589. skb->ip_summed = CHECKSUM_UNNECESSARY;
  590. else
  591. skb->ip_summed = CHECKSUM_NONE;
  592. }
  593. if (vlan_tci & VLAN_TAG_PRESENT)
  594. __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q),
  595. vlan_tci);
  596. skb_record_rx_queue(skb, channel->
  597. offermsg.offer.sub_channel_index);
  598. u64_stats_update_begin(&rx_stats->syncp);
  599. rx_stats->packets++;
  600. rx_stats->bytes += packet->total_data_buflen;
  601. u64_stats_update_end(&rx_stats->syncp);
  602. /*
  603. * Pass the skb back up. Network stack will deallocate the skb when it
  604. * is done.
  605. * TODO - use NAPI?
  606. */
  607. netif_rx(skb);
  608. return 0;
  609. }
  610. static void netvsc_get_drvinfo(struct net_device *net,
  611. struct ethtool_drvinfo *info)
  612. {
  613. strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver));
  614. strlcpy(info->fw_version, "N/A", sizeof(info->fw_version));
  615. }
  616. static void netvsc_get_channels(struct net_device *net,
  617. struct ethtool_channels *channel)
  618. {
  619. struct net_device_context *net_device_ctx = netdev_priv(net);
  620. struct hv_device *dev = net_device_ctx->device_ctx;
  621. struct netvsc_device *nvdev = hv_get_drvdata(dev);
  622. if (nvdev) {
  623. channel->max_combined = nvdev->max_chn;
  624. channel->combined_count = nvdev->num_chn;
  625. }
  626. }
  627. static int netvsc_set_channels(struct net_device *net,
  628. struct ethtool_channels *channels)
  629. {
  630. struct net_device_context *net_device_ctx = netdev_priv(net);
  631. struct hv_device *dev = net_device_ctx->device_ctx;
  632. struct netvsc_device *nvdev = hv_get_drvdata(dev);
  633. struct netvsc_device_info device_info;
  634. u32 num_chn;
  635. u32 max_chn;
  636. int ret = 0;
  637. bool recovering = false;
  638. if (!nvdev || nvdev->destroy)
  639. return -ENODEV;
  640. num_chn = nvdev->num_chn;
  641. max_chn = min_t(u32, nvdev->max_chn, num_online_cpus());
  642. if (nvdev->nvsp_version < NVSP_PROTOCOL_VERSION_5) {
  643. pr_info("vRSS unsupported before NVSP Version 5\n");
  644. return -EINVAL;
  645. }
  646. /* We do not support rx, tx, or other */
  647. if (!channels ||
  648. channels->rx_count ||
  649. channels->tx_count ||
  650. channels->other_count ||
  651. (channels->combined_count < 1))
  652. return -EINVAL;
  653. if (channels->combined_count > max_chn) {
  654. pr_info("combined channels too high, using %d\n", max_chn);
  655. channels->combined_count = max_chn;
  656. }
  657. ret = netvsc_close(net);
  658. if (ret)
  659. goto out;
  660. do_set:
  661. nvdev->start_remove = true;
  662. rndis_filter_device_remove(dev);
  663. nvdev->num_chn = channels->combined_count;
  664. net_device_ctx->device_ctx = dev;
  665. hv_set_drvdata(dev, net);
  666. memset(&device_info, 0, sizeof(device_info));
  667. device_info.num_chn = nvdev->num_chn; /* passed to RNDIS */
  668. device_info.ring_size = ring_size;
  669. device_info.max_num_vrss_chns = max_num_vrss_chns;
  670. ret = rndis_filter_device_add(dev, &device_info);
  671. if (ret) {
  672. if (recovering) {
  673. netdev_err(net, "unable to add netvsc device (ret %d)\n", ret);
  674. return ret;
  675. }
  676. goto recover;
  677. }
  678. nvdev = hv_get_drvdata(dev);
  679. ret = netif_set_real_num_tx_queues(net, nvdev->num_chn);
  680. if (ret) {
  681. if (recovering) {
  682. netdev_err(net, "could not set tx queue count (ret %d)\n", ret);
  683. return ret;
  684. }
  685. goto recover;
  686. }
  687. ret = netif_set_real_num_rx_queues(net, nvdev->num_chn);
  688. if (ret) {
  689. if (recovering) {
  690. netdev_err(net, "could not set rx queue count (ret %d)\n", ret);
  691. return ret;
  692. }
  693. goto recover;
  694. }
  695. out:
  696. netvsc_open(net);
  697. return ret;
  698. recover:
  699. /* If the above failed, we attempt to recover through the same
  700. * process but with the original number of channels.
  701. */
  702. netdev_err(net, "could not set channels, recovering\n");
  703. recovering = true;
  704. channels->combined_count = num_chn;
  705. goto do_set;
  706. }
  707. static int netvsc_change_mtu(struct net_device *ndev, int mtu)
  708. {
  709. struct net_device_context *ndevctx = netdev_priv(ndev);
  710. struct hv_device *hdev = ndevctx->device_ctx;
  711. struct netvsc_device *nvdev = hv_get_drvdata(hdev);
  712. struct netvsc_device_info device_info;
  713. int limit = ETH_DATA_LEN;
  714. int ret = 0;
  715. if (nvdev == NULL || nvdev->destroy)
  716. return -ENODEV;
  717. if (nvdev->nvsp_version >= NVSP_PROTOCOL_VERSION_2)
  718. limit = NETVSC_MTU - ETH_HLEN;
  719. if (mtu < NETVSC_MTU_MIN || mtu > limit)
  720. return -EINVAL;
  721. ret = netvsc_close(ndev);
  722. if (ret)
  723. goto out;
  724. nvdev->start_remove = true;
  725. rndis_filter_device_remove(hdev);
  726. ndev->mtu = mtu;
  727. ndevctx->device_ctx = hdev;
  728. hv_set_drvdata(hdev, ndev);
  729. memset(&device_info, 0, sizeof(device_info));
  730. device_info.ring_size = ring_size;
  731. device_info.num_chn = nvdev->num_chn;
  732. device_info.max_num_vrss_chns = max_num_vrss_chns;
  733. rndis_filter_device_add(hdev, &device_info);
  734. out:
  735. netvsc_open(ndev);
  736. return ret;
  737. }
  738. static struct rtnl_link_stats64 *netvsc_get_stats64(struct net_device *net,
  739. struct rtnl_link_stats64 *t)
  740. {
  741. struct net_device_context *ndev_ctx = netdev_priv(net);
  742. int cpu;
  743. for_each_possible_cpu(cpu) {
  744. struct netvsc_stats *tx_stats = per_cpu_ptr(ndev_ctx->tx_stats,
  745. cpu);
  746. struct netvsc_stats *rx_stats = per_cpu_ptr(ndev_ctx->rx_stats,
  747. cpu);
  748. u64 tx_packets, tx_bytes, rx_packets, rx_bytes;
  749. unsigned int start;
  750. do {
  751. start = u64_stats_fetch_begin_irq(&tx_stats->syncp);
  752. tx_packets = tx_stats->packets;
  753. tx_bytes = tx_stats->bytes;
  754. } while (u64_stats_fetch_retry_irq(&tx_stats->syncp, start));
  755. do {
  756. start = u64_stats_fetch_begin_irq(&rx_stats->syncp);
  757. rx_packets = rx_stats->packets;
  758. rx_bytes = rx_stats->bytes;
  759. } while (u64_stats_fetch_retry_irq(&rx_stats->syncp, start));
  760. t->tx_bytes += tx_bytes;
  761. t->tx_packets += tx_packets;
  762. t->rx_bytes += rx_bytes;
  763. t->rx_packets += rx_packets;
  764. }
  765. t->tx_dropped = net->stats.tx_dropped;
  766. t->tx_errors = net->stats.tx_dropped;
  767. t->rx_dropped = net->stats.rx_dropped;
  768. t->rx_errors = net->stats.rx_errors;
  769. return t;
  770. }
  771. static int netvsc_set_mac_addr(struct net_device *ndev, void *p)
  772. {
  773. struct net_device_context *ndevctx = netdev_priv(ndev);
  774. struct hv_device *hdev = ndevctx->device_ctx;
  775. struct sockaddr *addr = p;
  776. char save_adr[ETH_ALEN];
  777. unsigned char save_aatype;
  778. int err;
  779. memcpy(save_adr, ndev->dev_addr, ETH_ALEN);
  780. save_aatype = ndev->addr_assign_type;
  781. err = eth_mac_addr(ndev, p);
  782. if (err != 0)
  783. return err;
  784. err = rndis_filter_set_device_mac(hdev, addr->sa_data);
  785. if (err != 0) {
  786. /* roll back to saved MAC */
  787. memcpy(ndev->dev_addr, save_adr, ETH_ALEN);
  788. ndev->addr_assign_type = save_aatype;
  789. }
  790. return err;
  791. }
  792. #ifdef CONFIG_NET_POLL_CONTROLLER
  793. static void netvsc_poll_controller(struct net_device *net)
  794. {
  795. /* As netvsc_start_xmit() works synchronous we don't have to
  796. * trigger anything here.
  797. */
  798. }
  799. #endif
  800. static const struct ethtool_ops ethtool_ops = {
  801. .get_drvinfo = netvsc_get_drvinfo,
  802. .get_link = ethtool_op_get_link,
  803. .get_channels = netvsc_get_channels,
  804. .set_channels = netvsc_set_channels,
  805. };
  806. static const struct net_device_ops device_ops = {
  807. .ndo_open = netvsc_open,
  808. .ndo_stop = netvsc_close,
  809. .ndo_start_xmit = netvsc_start_xmit,
  810. .ndo_set_rx_mode = netvsc_set_multicast_list,
  811. .ndo_change_mtu = netvsc_change_mtu,
  812. .ndo_validate_addr = eth_validate_addr,
  813. .ndo_set_mac_address = netvsc_set_mac_addr,
  814. .ndo_select_queue = netvsc_select_queue,
  815. .ndo_get_stats64 = netvsc_get_stats64,
  816. #ifdef CONFIG_NET_POLL_CONTROLLER
  817. .ndo_poll_controller = netvsc_poll_controller,
  818. #endif
  819. };
  820. /*
  821. * Handle link status changes. For RNDIS_STATUS_NETWORK_CHANGE emulate link
  822. * down/up sequence. In case of RNDIS_STATUS_MEDIA_CONNECT when carrier is
  823. * present send GARP packet to network peers with netif_notify_peers().
  824. */
  825. static void netvsc_link_change(struct work_struct *w)
  826. {
  827. struct net_device_context *ndev_ctx;
  828. struct net_device *net;
  829. struct netvsc_device *net_device;
  830. struct rndis_device *rdev;
  831. struct netvsc_reconfig *event = NULL;
  832. bool notify = false, reschedule = false;
  833. unsigned long flags, next_reconfig, delay;
  834. ndev_ctx = container_of(w, struct net_device_context, dwork.work);
  835. net_device = hv_get_drvdata(ndev_ctx->device_ctx);
  836. rdev = net_device->extension;
  837. net = net_device->ndev;
  838. next_reconfig = ndev_ctx->last_reconfig + LINKCHANGE_INT;
  839. if (time_is_after_jiffies(next_reconfig)) {
  840. /* link_watch only sends one notification with current state
  841. * per second, avoid doing reconfig more frequently. Handle
  842. * wrap around.
  843. */
  844. delay = next_reconfig - jiffies;
  845. delay = delay < LINKCHANGE_INT ? delay : LINKCHANGE_INT;
  846. schedule_delayed_work(&ndev_ctx->dwork, delay);
  847. return;
  848. }
  849. ndev_ctx->last_reconfig = jiffies;
  850. spin_lock_irqsave(&ndev_ctx->lock, flags);
  851. if (!list_empty(&ndev_ctx->reconfig_events)) {
  852. event = list_first_entry(&ndev_ctx->reconfig_events,
  853. struct netvsc_reconfig, list);
  854. list_del(&event->list);
  855. reschedule = !list_empty(&ndev_ctx->reconfig_events);
  856. }
  857. spin_unlock_irqrestore(&ndev_ctx->lock, flags);
  858. if (!event)
  859. return;
  860. rtnl_lock();
  861. switch (event->event) {
  862. /* Only the following events are possible due to the check in
  863. * netvsc_linkstatus_callback()
  864. */
  865. case RNDIS_STATUS_MEDIA_CONNECT:
  866. if (rdev->link_state) {
  867. rdev->link_state = false;
  868. netif_carrier_on(net);
  869. netif_tx_wake_all_queues(net);
  870. } else {
  871. notify = true;
  872. }
  873. kfree(event);
  874. break;
  875. case RNDIS_STATUS_MEDIA_DISCONNECT:
  876. if (!rdev->link_state) {
  877. rdev->link_state = true;
  878. netif_carrier_off(net);
  879. netif_tx_stop_all_queues(net);
  880. }
  881. kfree(event);
  882. break;
  883. case RNDIS_STATUS_NETWORK_CHANGE:
  884. /* Only makes sense if carrier is present */
  885. if (!rdev->link_state) {
  886. rdev->link_state = true;
  887. netif_carrier_off(net);
  888. netif_tx_stop_all_queues(net);
  889. event->event = RNDIS_STATUS_MEDIA_CONNECT;
  890. spin_lock_irqsave(&ndev_ctx->lock, flags);
  891. list_add_tail(&event->list, &ndev_ctx->reconfig_events);
  892. spin_unlock_irqrestore(&ndev_ctx->lock, flags);
  893. reschedule = true;
  894. }
  895. break;
  896. }
  897. rtnl_unlock();
  898. if (notify)
  899. netdev_notify_peers(net);
  900. /* link_watch only sends one notification with current state per
  901. * second, handle next reconfig event in 2 seconds.
  902. */
  903. if (reschedule)
  904. schedule_delayed_work(&ndev_ctx->dwork, LINKCHANGE_INT);
  905. }
  906. static void netvsc_free_netdev(struct net_device *netdev)
  907. {
  908. struct net_device_context *net_device_ctx = netdev_priv(netdev);
  909. free_percpu(net_device_ctx->tx_stats);
  910. free_percpu(net_device_ctx->rx_stats);
  911. free_netdev(netdev);
  912. }
  913. static int netvsc_probe(struct hv_device *dev,
  914. const struct hv_vmbus_device_id *dev_id)
  915. {
  916. struct net_device *net = NULL;
  917. struct net_device_context *net_device_ctx;
  918. struct netvsc_device_info device_info;
  919. struct netvsc_device *nvdev;
  920. int ret;
  921. net = alloc_etherdev_mq(sizeof(struct net_device_context),
  922. num_online_cpus());
  923. if (!net)
  924. return -ENOMEM;
  925. netif_carrier_off(net);
  926. net_device_ctx = netdev_priv(net);
  927. net_device_ctx->device_ctx = dev;
  928. net_device_ctx->msg_enable = netif_msg_init(debug, default_msg);
  929. if (netif_msg_probe(net_device_ctx))
  930. netdev_dbg(net, "netvsc msg_enable: %d\n",
  931. net_device_ctx->msg_enable);
  932. net_device_ctx->tx_stats = netdev_alloc_pcpu_stats(struct netvsc_stats);
  933. if (!net_device_ctx->tx_stats) {
  934. free_netdev(net);
  935. return -ENOMEM;
  936. }
  937. net_device_ctx->rx_stats = netdev_alloc_pcpu_stats(struct netvsc_stats);
  938. if (!net_device_ctx->rx_stats) {
  939. free_percpu(net_device_ctx->tx_stats);
  940. free_netdev(net);
  941. return -ENOMEM;
  942. }
  943. hv_set_drvdata(dev, net);
  944. INIT_DELAYED_WORK(&net_device_ctx->dwork, netvsc_link_change);
  945. INIT_WORK(&net_device_ctx->work, do_set_multicast);
  946. spin_lock_init(&net_device_ctx->lock);
  947. INIT_LIST_HEAD(&net_device_ctx->reconfig_events);
  948. net->netdev_ops = &device_ops;
  949. net->hw_features = NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_IP_CSUM |
  950. NETIF_F_TSO;
  951. net->features = NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_SG | NETIF_F_RXCSUM |
  952. NETIF_F_IP_CSUM | NETIF_F_TSO;
  953. net->ethtool_ops = &ethtool_ops;
  954. SET_NETDEV_DEV(net, &dev->device);
  955. /* Notify the netvsc driver of the new device */
  956. memset(&device_info, 0, sizeof(device_info));
  957. device_info.ring_size = ring_size;
  958. device_info.max_num_vrss_chns = max_num_vrss_chns;
  959. ret = rndis_filter_device_add(dev, &device_info);
  960. if (ret != 0) {
  961. netdev_err(net, "unable to add netvsc device (ret %d)\n", ret);
  962. netvsc_free_netdev(net);
  963. hv_set_drvdata(dev, NULL);
  964. return ret;
  965. }
  966. memcpy(net->dev_addr, device_info.mac_adr, ETH_ALEN);
  967. nvdev = hv_get_drvdata(dev);
  968. netif_set_real_num_tx_queues(net, nvdev->num_chn);
  969. netif_set_real_num_rx_queues(net, nvdev->num_chn);
  970. ret = register_netdev(net);
  971. if (ret != 0) {
  972. pr_err("Unable to register netdev.\n");
  973. rndis_filter_device_remove(dev);
  974. netvsc_free_netdev(net);
  975. }
  976. return ret;
  977. }
  978. static int netvsc_remove(struct hv_device *dev)
  979. {
  980. struct net_device *net;
  981. struct net_device_context *ndev_ctx;
  982. struct netvsc_device *net_device;
  983. net_device = hv_get_drvdata(dev);
  984. net = net_device->ndev;
  985. if (net == NULL) {
  986. dev_err(&dev->device, "No net device to remove\n");
  987. return 0;
  988. }
  989. net_device->start_remove = true;
  990. ndev_ctx = netdev_priv(net);
  991. cancel_delayed_work_sync(&ndev_ctx->dwork);
  992. cancel_work_sync(&ndev_ctx->work);
  993. /* Stop outbound asap */
  994. netif_tx_disable(net);
  995. unregister_netdev(net);
  996. /*
  997. * Call to the vsc driver to let it know that the device is being
  998. * removed
  999. */
  1000. rndis_filter_device_remove(dev);
  1001. netvsc_free_netdev(net);
  1002. return 0;
  1003. }
  1004. static const struct hv_vmbus_device_id id_table[] = {
  1005. /* Network guid */
  1006. { HV_NIC_GUID, },
  1007. { },
  1008. };
  1009. MODULE_DEVICE_TABLE(vmbus, id_table);
  1010. /* The one and only one */
  1011. static struct hv_driver netvsc_drv = {
  1012. .name = KBUILD_MODNAME,
  1013. .id_table = id_table,
  1014. .probe = netvsc_probe,
  1015. .remove = netvsc_remove,
  1016. };
  1017. static void __exit netvsc_drv_exit(void)
  1018. {
  1019. vmbus_driver_unregister(&netvsc_drv);
  1020. }
  1021. static int __init netvsc_drv_init(void)
  1022. {
  1023. if (ring_size < RING_SIZE_MIN) {
  1024. ring_size = RING_SIZE_MIN;
  1025. pr_info("Increased ring_size to %d (min allowed)\n",
  1026. ring_size);
  1027. }
  1028. return vmbus_driver_register(&netvsc_drv);
  1029. }
  1030. MODULE_LICENSE("GPL");
  1031. MODULE_DESCRIPTION("Microsoft Hyper-V network driver");
  1032. module_init(netvsc_drv_init);
  1033. module_exit(netvsc_drv_exit);