Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 1 | /* |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 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, write to the Free Software Foundation, Inc., 59 Temple |
| 15 | * Place - Suite 330, Boston, MA 02111-1307 USA. |
| 16 | * |
| 17 | * Authors: |
Haiyang Zhang | d0e94d1 | 2009-11-23 17:00:22 +0000 | [diff] [blame] | 18 | * Haiyang Zhang <haiyangz@microsoft.com> |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 19 | * Hank Janssen <hjanssen@microsoft.com> |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 20 | */ |
Hank Janssen | eb335bc | 2011-03-29 13:58:48 -0700 | [diff] [blame] | 21 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 22 | |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 23 | #include <linux/init.h> |
K. Y. Srinivasan | 9079ce6 | 2011-06-16 13:16:37 -0700 | [diff] [blame] | 24 | #include <linux/atomic.h> |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 25 | #include <linux/module.h> |
| 26 | #include <linux/highmem.h> |
| 27 | #include <linux/device.h> |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 28 | #include <linux/io.h> |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 29 | #include <linux/delay.h> |
| 30 | #include <linux/netdevice.h> |
| 31 | #include <linux/inetdevice.h> |
| 32 | #include <linux/etherdevice.h> |
| 33 | #include <linux/skbuff.h> |
| 34 | #include <linux/in.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 35 | #include <linux/slab.h> |
K. Y. Srinivasan | 06e719d | 2010-05-07 17:52:17 -0600 | [diff] [blame] | 36 | #include <linux/dmi.h> |
| 37 | #include <linux/pci.h> |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 38 | #include <net/arp.h> |
| 39 | #include <net/route.h> |
| 40 | #include <net/sock.h> |
| 41 | #include <net/pkt_sched.h> |
K. Y. Srinivasan | 3f335ea | 2011-05-12 19:34:15 -0700 | [diff] [blame] | 42 | |
| 43 | #include "hyperv.h" |
K. Y. Srinivasan | 5ca7252 | 2011-05-12 19:34:37 -0700 | [diff] [blame] | 44 | #include "hyperv_net.h" |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 45 | |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 46 | struct net_device_context { |
Greg Kroah-Hartman | 02fafbc | 2009-08-31 21:09:45 -0700 | [diff] [blame] | 47 | /* point back to our device context */ |
K. Y. Srinivasan | 6bad88da | 2011-03-07 13:35:48 -0800 | [diff] [blame] | 48 | struct hv_device *device_ctx; |
K. Y. Srinivasan | 9079ce6 | 2011-06-16 13:16:37 -0700 | [diff] [blame] | 49 | atomic_t avail; |
Haiyang Zhang | 122a5f6 | 2011-05-27 06:21:55 -0700 | [diff] [blame] | 50 | struct delayed_work dwork; |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 51 | }; |
| 52 | |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 53 | |
Stephen Hemminger | b220f5f | 2010-05-04 09:58:56 -0700 | [diff] [blame] | 54 | #define PACKET_PAGES_LOWATER 8 |
| 55 | /* Need this many pages to handle worst case fragmented packet */ |
| 56 | #define PACKET_PAGES_HIWATER (MAX_SKB_FRAGS + 2) |
| 57 | |
Hank Janssen | 99c8da0 | 2010-10-12 10:45:23 -0700 | [diff] [blame] | 58 | static int ring_size = 128; |
Stephen Hemminger | 450d7a4 | 2010-05-04 09:58:53 -0700 | [diff] [blame] | 59 | module_param(ring_size, int, S_IRUGO); |
| 60 | MODULE_PARM_DESC(ring_size, "Ring buffer size (# of pages)"); |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 61 | |
Brandon Philips | 0ff36f69 | 2010-11-15 11:55:33 -0800 | [diff] [blame] | 62 | /* no-op so the netdev core doesn't return -EINVAL when modifying the the |
| 63 | * multicast address list in SIOCADDMULTI. hv is setup to get all multicast |
| 64 | * when it calls RndisFilterOnOpen() */ |
Greg Kroah-Hartman | 4e9bfef | 2009-07-15 12:45:20 -0700 | [diff] [blame] | 65 | static void netvsc_set_multicast_list(struct net_device *net) |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 66 | { |
| 67 | } |
| 68 | |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 69 | static int netvsc_open(struct net_device *net) |
| 70 | { |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 71 | struct net_device_context *net_device_ctx = netdev_priv(net); |
K. Y. Srinivasan | 6bad88da | 2011-03-07 13:35:48 -0800 | [diff] [blame] | 72 | struct hv_device *device_obj = net_device_ctx->device_ctx; |
Greg Kroah-Hartman | 02fafbc | 2009-08-31 21:09:45 -0700 | [diff] [blame] | 73 | int ret = 0; |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 74 | |
Greg Kroah-Hartman | 02fafbc | 2009-08-31 21:09:45 -0700 | [diff] [blame] | 75 | if (netif_carrier_ok(net)) { |
Bill Pemberton | 454f18a | 2009-07-27 16:47:24 -0400 | [diff] [blame] | 76 | /* Open up the device */ |
Haiyang Zhang | 9c26aa0 | 2010-12-10 12:03:57 -0800 | [diff] [blame] | 77 | ret = rndis_filter_open(device_obj); |
Greg Kroah-Hartman | 02fafbc | 2009-08-31 21:09:45 -0700 | [diff] [blame] | 78 | if (ret != 0) { |
Hank Janssen | eb335bc | 2011-03-29 13:58:48 -0700 | [diff] [blame] | 79 | netdev_err(net, "unable to open device (ret %d).\n", |
| 80 | ret); |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 81 | return ret; |
| 82 | } |
| 83 | |
| 84 | netif_start_queue(net); |
Greg Kroah-Hartman | 02fafbc | 2009-08-31 21:09:45 -0700 | [diff] [blame] | 85 | } else { |
Hank Janssen | eb335bc | 2011-03-29 13:58:48 -0700 | [diff] [blame] | 86 | netdev_err(net, "unable to open device...link is down.\n"); |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 87 | } |
| 88 | |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 89 | return ret; |
| 90 | } |
| 91 | |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 92 | static int netvsc_close(struct net_device *net) |
| 93 | { |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 94 | struct net_device_context *net_device_ctx = netdev_priv(net); |
K. Y. Srinivasan | 6bad88da | 2011-03-07 13:35:48 -0800 | [diff] [blame] | 95 | struct hv_device *device_obj = net_device_ctx->device_ctx; |
Greg Kroah-Hartman | 02fafbc | 2009-08-31 21:09:45 -0700 | [diff] [blame] | 96 | int ret; |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 97 | |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 98 | netif_stop_queue(net); |
| 99 | |
Haiyang Zhang | 9c26aa0 | 2010-12-10 12:03:57 -0800 | [diff] [blame] | 100 | ret = rndis_filter_close(device_obj); |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 101 | if (ret != 0) |
Hank Janssen | eb335bc | 2011-03-29 13:58:48 -0700 | [diff] [blame] | 102 | netdev_err(net, "unable to close device (ret %d).\n", ret); |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 103 | |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 104 | return ret; |
| 105 | } |
| 106 | |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 107 | static void netvsc_xmit_completion(void *context) |
| 108 | { |
Nicolas Palix | 4193d4f | 2009-07-29 14:10:10 +0200 | [diff] [blame] | 109 | struct hv_netvsc_packet *packet = (struct hv_netvsc_packet *)context; |
Greg Kroah-Hartman | 02fafbc | 2009-08-31 21:09:45 -0700 | [diff] [blame] | 110 | struct sk_buff *skb = (struct sk_buff *) |
Haiyang Zhang | 72a2f5b | 2010-12-10 12:03:58 -0800 | [diff] [blame] | 111 | (unsigned long)packet->completion.send.send_completion_tid; |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 112 | |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 113 | kfree(packet); |
| 114 | |
Greg Kroah-Hartman | 02fafbc | 2009-08-31 21:09:45 -0700 | [diff] [blame] | 115 | if (skb) { |
Stephen Hemminger | 7880fc5 | 2010-05-04 09:58:52 -0700 | [diff] [blame] | 116 | struct net_device *net = skb->dev; |
Stephen Hemminger | b220f5f | 2010-05-04 09:58:56 -0700 | [diff] [blame] | 117 | struct net_device_context *net_device_ctx = netdev_priv(net); |
| 118 | unsigned int num_pages = skb_shinfo(skb)->nr_frags + 2; |
| 119 | |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 120 | dev_kfree_skb_any(skb); |
| 121 | |
K. Y. Srinivasan | 9079ce6 | 2011-06-16 13:16:37 -0700 | [diff] [blame] | 122 | atomic_add(num_pages, &net_device_ctx->avail); |
| 123 | if (atomic_read(&net_device_ctx->avail) >= |
| 124 | PACKET_PAGES_HIWATER) |
Haiyang Zhang | e4d59ac | 2011-06-17 07:58:04 -0700 | [diff] [blame] | 125 | netif_wake_queue(net); |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 126 | } |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 127 | } |
| 128 | |
Greg Kroah-Hartman | 02fafbc | 2009-08-31 21:09:45 -0700 | [diff] [blame] | 129 | static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net) |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 130 | { |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 131 | struct net_device_context *net_device_ctx = netdev_priv(net); |
Nicolas Palix | 4193d4f | 2009-07-29 14:10:10 +0200 | [diff] [blame] | 132 | struct hv_netvsc_packet *packet; |
Greg Kroah-Hartman | 02fafbc | 2009-08-31 21:09:45 -0700 | [diff] [blame] | 133 | int ret; |
Stephen Hemminger | 6048718 | 2010-05-04 09:58:55 -0700 | [diff] [blame] | 134 | unsigned int i, num_pages; |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 135 | |
Stephen Hemminger | 6048718 | 2010-05-04 09:58:55 -0700 | [diff] [blame] | 136 | /* Add 1 for skb->data and additional one for RNDIS */ |
| 137 | num_pages = skb_shinfo(skb)->nr_frags + 1 + 1; |
K. Y. Srinivasan | 9079ce6 | 2011-06-16 13:16:37 -0700 | [diff] [blame] | 138 | if (num_pages > atomic_read(&net_device_ctx->avail)) |
Stephen Hemminger | b220f5f | 2010-05-04 09:58:56 -0700 | [diff] [blame] | 139 | return NETDEV_TX_BUSY; |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 140 | |
Bill Pemberton | 454f18a | 2009-07-27 16:47:24 -0400 | [diff] [blame] | 141 | /* Allocate a netvsc packet based on # of frags. */ |
Greg Kroah-Hartman | 02fafbc | 2009-08-31 21:09:45 -0700 | [diff] [blame] | 142 | packet = kzalloc(sizeof(struct hv_netvsc_packet) + |
Stephen Hemminger | 6048718 | 2010-05-04 09:58:55 -0700 | [diff] [blame] | 143 | (num_pages * sizeof(struct hv_page_buffer)) + |
K. Y. Srinivasan | f8ba8c7 | 2011-05-12 19:35:01 -0700 | [diff] [blame] | 144 | sizeof(struct rndis_filter_packet), GFP_ATOMIC); |
Greg Kroah-Hartman | 02fafbc | 2009-08-31 21:09:45 -0700 | [diff] [blame] | 145 | if (!packet) { |
Stephen Hemminger | b220f5f | 2010-05-04 09:58:56 -0700 | [diff] [blame] | 146 | /* out of memory, silently drop packet */ |
Hank Janssen | eb335bc | 2011-03-29 13:58:48 -0700 | [diff] [blame] | 147 | netdev_err(net, "unable to allocate hv_netvsc_packet\n"); |
Stephen Hemminger | b220f5f | 2010-05-04 09:58:56 -0700 | [diff] [blame] | 148 | |
| 149 | dev_kfree_skb(skb); |
| 150 | net->stats.tx_dropped++; |
| 151 | return NETDEV_TX_OK; |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 152 | } |
| 153 | |
Haiyang Zhang | 72a2f5b | 2010-12-10 12:03:58 -0800 | [diff] [blame] | 154 | packet->extension = (void *)(unsigned long)packet + |
Greg Kroah-Hartman | 02fafbc | 2009-08-31 21:09:45 -0700 | [diff] [blame] | 155 | sizeof(struct hv_netvsc_packet) + |
Stephen Hemminger | 6048718 | 2010-05-04 09:58:55 -0700 | [diff] [blame] | 156 | (num_pages * sizeof(struct hv_page_buffer)); |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 157 | |
Bill Pemberton | 454f18a | 2009-07-27 16:47:24 -0400 | [diff] [blame] | 158 | /* Setup the rndis header */ |
Haiyang Zhang | 72a2f5b | 2010-12-10 12:03:58 -0800 | [diff] [blame] | 159 | packet->page_buf_cnt = num_pages; |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 160 | |
Bill Pemberton | 454f18a | 2009-07-27 16:47:24 -0400 | [diff] [blame] | 161 | /* Initialize it from the skb */ |
Haiyang Zhang | 72a2f5b | 2010-12-10 12:03:58 -0800 | [diff] [blame] | 162 | packet->total_data_buflen = skb->len; |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 163 | |
Stephen Hemminger | 6048718 | 2010-05-04 09:58:55 -0700 | [diff] [blame] | 164 | /* Start filling in the page buffers starting after RNDIS buffer. */ |
Haiyang Zhang | ca623ad | 2011-01-26 12:12:11 -0800 | [diff] [blame] | 165 | packet->page_buf[1].pfn = virt_to_phys(skb->data) >> PAGE_SHIFT; |
| 166 | packet->page_buf[1].offset |
Stephen Hemminger | 6048718 | 2010-05-04 09:58:55 -0700 | [diff] [blame] | 167 | = (unsigned long)skb->data & (PAGE_SIZE - 1); |
Haiyang Zhang | ca623ad | 2011-01-26 12:12:11 -0800 | [diff] [blame] | 168 | packet->page_buf[1].len = skb_headlen(skb); |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 169 | |
Stephen Hemminger | 6048718 | 2010-05-04 09:58:55 -0700 | [diff] [blame] | 170 | /* Additional fragments are after SKB data */ |
| 171 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { |
| 172 | skb_frag_t *f = &skb_shinfo(skb)->frags[i]; |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 173 | |
Haiyang Zhang | ca623ad | 2011-01-26 12:12:11 -0800 | [diff] [blame] | 174 | packet->page_buf[i+2].pfn = page_to_pfn(f->page); |
| 175 | packet->page_buf[i+2].offset = f->page_offset; |
| 176 | packet->page_buf[i+2].len = f->size; |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 177 | } |
| 178 | |
Bill Pemberton | 454f18a | 2009-07-27 16:47:24 -0400 | [diff] [blame] | 179 | /* Set the completion routine */ |
Haiyang Zhang | 72a2f5b | 2010-12-10 12:03:58 -0800 | [diff] [blame] | 180 | packet->completion.send.send_completion = netvsc_xmit_completion; |
| 181 | packet->completion.send.send_completion_ctx = packet; |
| 182 | packet->completion.send.send_completion_tid = (unsigned long)skb; |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 183 | |
K. Y. Srinivasan | 55acb69 | 2011-05-12 19:34:54 -0700 | [diff] [blame] | 184 | ret = rndis_filter_send(net_device_ctx->device_ctx, |
Greg Kroah-Hartman | 02fafbc | 2009-08-31 21:09:45 -0700 | [diff] [blame] | 185 | packet); |
Greg Kroah-Hartman | 02fafbc | 2009-08-31 21:09:45 -0700 | [diff] [blame] | 186 | if (ret == 0) { |
Stephen Hemminger | b852fdc | 2010-03-09 17:42:33 -0800 | [diff] [blame] | 187 | net->stats.tx_bytes += skb->len; |
| 188 | net->stats.tx_packets++; |
Stephen Hemminger | b220f5f | 2010-05-04 09:58:56 -0700 | [diff] [blame] | 189 | |
K. Y. Srinivasan | 9079ce6 | 2011-06-16 13:16:37 -0700 | [diff] [blame] | 190 | atomic_sub(num_pages, &net_device_ctx->avail); |
| 191 | if (atomic_read(&net_device_ctx->avail) < PACKET_PAGES_LOWATER) |
Stephen Hemminger | b220f5f | 2010-05-04 09:58:56 -0700 | [diff] [blame] | 192 | netif_stop_queue(net); |
Greg Kroah-Hartman | 02fafbc | 2009-08-31 21:09:45 -0700 | [diff] [blame] | 193 | } else { |
Stephen Hemminger | b220f5f | 2010-05-04 09:58:56 -0700 | [diff] [blame] | 194 | /* we are shutting down or bus overloaded, just drop packet */ |
Stephen Hemminger | b852fdc | 2010-03-09 17:42:33 -0800 | [diff] [blame] | 195 | net->stats.tx_dropped++; |
Stephen Hemminger | b220f5f | 2010-05-04 09:58:56 -0700 | [diff] [blame] | 196 | netvsc_xmit_completion(packet); |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 197 | } |
| 198 | |
Stephen Hemminger | b220f5f | 2010-05-04 09:58:56 -0700 | [diff] [blame] | 199 | return NETDEV_TX_OK; |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 200 | } |
| 201 | |
Hank Janssen | 3e18951 | 2010-03-04 22:11:00 +0000 | [diff] [blame] | 202 | /* |
Greg Kroah-Hartman | 02fafbc | 2009-08-31 21:09:45 -0700 | [diff] [blame] | 203 | * netvsc_linkstatus_callback - Link up/down notification |
| 204 | */ |
K. Y. Srinivasan | 90ef117 | 2011-05-12 19:34:50 -0700 | [diff] [blame] | 205 | void netvsc_linkstatus_callback(struct hv_device *device_obj, |
Greg Kroah-Hartman | 02fafbc | 2009-08-31 21:09:45 -0700 | [diff] [blame] | 206 | unsigned int status) |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 207 | { |
K. Y. Srinivasan | 6bad88da | 2011-03-07 13:35:48 -0800 | [diff] [blame] | 208 | struct net_device *net = dev_get_drvdata(&device_obj->device); |
Haiyang Zhang | c996edc | 2011-04-06 15:18:00 -0700 | [diff] [blame] | 209 | struct net_device_context *ndev_ctx; |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 210 | |
Greg Kroah-Hartman | 02fafbc | 2009-08-31 21:09:45 -0700 | [diff] [blame] | 211 | if (!net) { |
Hank Janssen | eb335bc | 2011-03-29 13:58:48 -0700 | [diff] [blame] | 212 | netdev_err(net, "got link status but net device " |
| 213 | "not initialized yet\n"); |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 214 | return; |
| 215 | } |
| 216 | |
Greg Kroah-Hartman | 02fafbc | 2009-08-31 21:09:45 -0700 | [diff] [blame] | 217 | if (status == 1) { |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 218 | netif_carrier_on(net); |
| 219 | netif_wake_queue(net); |
Haiyang Zhang | 7c161d0 | 2011-02-02 13:42:58 -0800 | [diff] [blame] | 220 | netif_notify_peers(net); |
Haiyang Zhang | c996edc | 2011-04-06 15:18:00 -0700 | [diff] [blame] | 221 | ndev_ctx = netdev_priv(net); |
Haiyang Zhang | 122a5f6 | 2011-05-27 06:21:55 -0700 | [diff] [blame] | 222 | schedule_delayed_work(&ndev_ctx->dwork, msecs_to_jiffies(20)); |
Greg Kroah-Hartman | 02fafbc | 2009-08-31 21:09:45 -0700 | [diff] [blame] | 223 | } else { |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 224 | netif_carrier_off(net); |
| 225 | netif_stop_queue(net); |
| 226 | } |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 227 | } |
| 228 | |
Hank Janssen | 3e18951 | 2010-03-04 22:11:00 +0000 | [diff] [blame] | 229 | /* |
| 230 | * netvsc_recv_callback - Callback when we receive a packet from the |
| 231 | * "wire" on the specified device. |
Greg Kroah-Hartman | 02fafbc | 2009-08-31 21:09:45 -0700 | [diff] [blame] | 232 | */ |
K. Y. Srinivasan | f79adf8 | 2011-05-12 19:34:51 -0700 | [diff] [blame] | 233 | int netvsc_recv_callback(struct hv_device *device_obj, |
Greg Kroah-Hartman | 02fafbc | 2009-08-31 21:09:45 -0700 | [diff] [blame] | 234 | struct hv_netvsc_packet *packet) |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 235 | { |
K. Y. Srinivasan | 6bad88da | 2011-03-07 13:35:48 -0800 | [diff] [blame] | 236 | struct net_device *net = dev_get_drvdata(&device_obj->device); |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 237 | struct sk_buff *skb; |
| 238 | void *data; |
Greg Kroah-Hartman | 02fafbc | 2009-08-31 21:09:45 -0700 | [diff] [blame] | 239 | int i; |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 240 | unsigned long flags; |
| 241 | |
Greg Kroah-Hartman | 02fafbc | 2009-08-31 21:09:45 -0700 | [diff] [blame] | 242 | if (!net) { |
Hank Janssen | eb335bc | 2011-03-29 13:58:48 -0700 | [diff] [blame] | 243 | netdev_err(net, "got receive callback but net device" |
| 244 | " not initialized yet\n"); |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 245 | return 0; |
| 246 | } |
| 247 | |
Stephen Hemminger | 9495c28 | 2010-03-09 17:42:17 -0800 | [diff] [blame] | 248 | /* Allocate a skb - TODO direct I/O to pages? */ |
Haiyang Zhang | 72a2f5b | 2010-12-10 12:03:58 -0800 | [diff] [blame] | 249 | skb = netdev_alloc_skb_ip_align(net, packet->total_data_buflen); |
Stephen Hemminger | 9495c28 | 2010-03-09 17:42:17 -0800 | [diff] [blame] | 250 | if (unlikely(!skb)) { |
| 251 | ++net->stats.rx_dropped; |
| 252 | return 0; |
| 253 | } |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 254 | |
Bill Pemberton | 454f18a | 2009-07-27 16:47:24 -0400 | [diff] [blame] | 255 | /* for kmap_atomic */ |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 256 | local_irq_save(flags); |
| 257 | |
Greg Kroah-Hartman | 02fafbc | 2009-08-31 21:09:45 -0700 | [diff] [blame] | 258 | /* |
| 259 | * Copy to skb. This copy is needed here since the memory pointed by |
| 260 | * hv_netvsc_packet cannot be deallocated |
| 261 | */ |
Haiyang Zhang | 72a2f5b | 2010-12-10 12:03:58 -0800 | [diff] [blame] | 262 | for (i = 0; i < packet->page_buf_cnt; i++) { |
Haiyang Zhang | ca623ad | 2011-01-26 12:12:11 -0800 | [diff] [blame] | 263 | data = kmap_atomic(pfn_to_page(packet->page_buf[i].pfn), |
Greg Kroah-Hartman | 02fafbc | 2009-08-31 21:09:45 -0700 | [diff] [blame] | 264 | KM_IRQ1); |
| 265 | data = (void *)(unsigned long)data + |
Haiyang Zhang | ca623ad | 2011-01-26 12:12:11 -0800 | [diff] [blame] | 266 | packet->page_buf[i].offset; |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 267 | |
Haiyang Zhang | ca623ad | 2011-01-26 12:12:11 -0800 | [diff] [blame] | 268 | memcpy(skb_put(skb, packet->page_buf[i].len), data, |
| 269 | packet->page_buf[i].len); |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 270 | |
Greg Kroah-Hartman | 02fafbc | 2009-08-31 21:09:45 -0700 | [diff] [blame] | 271 | kunmap_atomic((void *)((unsigned long)data - |
Haiyang Zhang | ca623ad | 2011-01-26 12:12:11 -0800 | [diff] [blame] | 272 | packet->page_buf[i].offset), KM_IRQ1); |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 273 | } |
| 274 | |
| 275 | local_irq_restore(flags); |
| 276 | |
| 277 | skb->protocol = eth_type_trans(skb, net); |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 278 | skb->ip_summed = CHECKSUM_NONE; |
| 279 | |
Stephen Hemminger | 9495c28 | 2010-03-09 17:42:17 -0800 | [diff] [blame] | 280 | net->stats.rx_packets++; |
| 281 | net->stats.rx_bytes += skb->len; |
| 282 | |
Greg Kroah-Hartman | 02fafbc | 2009-08-31 21:09:45 -0700 | [diff] [blame] | 283 | /* |
| 284 | * Pass the skb back up. Network stack will deallocate the skb when it |
Stephen Hemminger | 9495c28 | 2010-03-09 17:42:17 -0800 | [diff] [blame] | 285 | * is done. |
| 286 | * TODO - use NAPI? |
Greg Kroah-Hartman | 02fafbc | 2009-08-31 21:09:45 -0700 | [diff] [blame] | 287 | */ |
Stephen Hemminger | 9495c28 | 2010-03-09 17:42:17 -0800 | [diff] [blame] | 288 | netif_rx(skb); |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 289 | |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 290 | return 0; |
| 291 | } |
| 292 | |
Stephen Hemminger | f82f4ad | 2010-05-04 09:58:57 -0700 | [diff] [blame] | 293 | static void netvsc_get_drvinfo(struct net_device *net, |
| 294 | struct ethtool_drvinfo *info) |
| 295 | { |
| 296 | strcpy(info->driver, "hv_netvsc"); |
| 297 | strcpy(info->version, HV_DRV_VERSION); |
| 298 | strcpy(info->fw_version, "N/A"); |
| 299 | } |
| 300 | |
| 301 | static const struct ethtool_ops ethtool_ops = { |
| 302 | .get_drvinfo = netvsc_get_drvinfo, |
Stephen Hemminger | f82f4ad | 2010-05-04 09:58:57 -0700 | [diff] [blame] | 303 | .get_link = ethtool_op_get_link, |
| 304 | }; |
| 305 | |
Greg Kroah-Hartman | df2fff2 | 2009-08-31 21:11:12 -0700 | [diff] [blame] | 306 | static const struct net_device_ops device_ops = { |
| 307 | .ndo_open = netvsc_open, |
| 308 | .ndo_stop = netvsc_close, |
| 309 | .ndo_start_xmit = netvsc_start_xmit, |
Greg Kroah-Hartman | df2fff2 | 2009-08-31 21:11:12 -0700 | [diff] [blame] | 310 | .ndo_set_multicast_list = netvsc_set_multicast_list, |
Haiyang Zhang | b681b58 | 2010-08-03 19:15:31 +0000 | [diff] [blame] | 311 | .ndo_change_mtu = eth_change_mtu, |
| 312 | .ndo_validate_addr = eth_validate_addr, |
| 313 | .ndo_set_mac_address = eth_mac_addr, |
Greg Kroah-Hartman | df2fff2 | 2009-08-31 21:11:12 -0700 | [diff] [blame] | 314 | }; |
| 315 | |
Haiyang Zhang | c996edc | 2011-04-06 15:18:00 -0700 | [diff] [blame] | 316 | /* |
| 317 | * Send GARP packet to network peers after migrations. |
| 318 | * After Quick Migration, the network is not immediately operational in the |
| 319 | * current context when receiving RNDIS_STATUS_MEDIA_CONNECT event. So, add |
Haiyang Zhang | 122a5f6 | 2011-05-27 06:21:55 -0700 | [diff] [blame] | 320 | * another netif_notify_peers() into a delayed work, otherwise GARP packet |
Haiyang Zhang | c996edc | 2011-04-06 15:18:00 -0700 | [diff] [blame] | 321 | * will not be sent after quick migration, and cause network disconnection. |
| 322 | */ |
| 323 | static void netvsc_send_garp(struct work_struct *w) |
| 324 | { |
| 325 | struct net_device_context *ndev_ctx; |
| 326 | struct net_device *net; |
| 327 | |
Haiyang Zhang | 122a5f6 | 2011-05-27 06:21:55 -0700 | [diff] [blame] | 328 | ndev_ctx = container_of(w, struct net_device_context, dwork.work); |
Haiyang Zhang | c996edc | 2011-04-06 15:18:00 -0700 | [diff] [blame] | 329 | net = dev_get_drvdata(&ndev_ctx->device_ctx->device); |
| 330 | netif_notify_peers(net); |
| 331 | } |
| 332 | |
| 333 | |
K. Y. Srinivasan | 9efd21e | 2011-04-29 13:45:10 -0700 | [diff] [blame] | 334 | static int netvsc_probe(struct hv_device *dev) |
Greg Kroah-Hartman | df2fff2 | 2009-08-31 21:11:12 -0700 | [diff] [blame] | 335 | { |
Greg Kroah-Hartman | df2fff2 | 2009-08-31 21:11:12 -0700 | [diff] [blame] | 336 | struct net_device *net = NULL; |
| 337 | struct net_device_context *net_device_ctx; |
| 338 | struct netvsc_device_info device_info; |
| 339 | int ret; |
| 340 | |
Stephen Hemminger | 546d9e1 | 2010-03-11 09:11:37 -0800 | [diff] [blame] | 341 | net = alloc_etherdev(sizeof(struct net_device_context)); |
Greg Kroah-Hartman | df2fff2 | 2009-08-31 21:11:12 -0700 | [diff] [blame] | 342 | if (!net) |
| 343 | return -1; |
| 344 | |
| 345 | /* Set initial state */ |
| 346 | netif_carrier_off(net); |
Greg Kroah-Hartman | df2fff2 | 2009-08-31 21:11:12 -0700 | [diff] [blame] | 347 | |
| 348 | net_device_ctx = netdev_priv(net); |
K. Y. Srinivasan | 9efd21e | 2011-04-29 13:45:10 -0700 | [diff] [blame] | 349 | net_device_ctx->device_ctx = dev; |
K. Y. Srinivasan | 9079ce6 | 2011-06-16 13:16:37 -0700 | [diff] [blame] | 350 | atomic_set(&net_device_ctx->avail, ring_size); |
K. Y. Srinivasan | 9efd21e | 2011-04-29 13:45:10 -0700 | [diff] [blame] | 351 | dev_set_drvdata(&dev->device, net); |
Haiyang Zhang | 122a5f6 | 2011-05-27 06:21:55 -0700 | [diff] [blame] | 352 | INIT_DELAYED_WORK(&net_device_ctx->dwork, netvsc_send_garp); |
Greg Kroah-Hartman | df2fff2 | 2009-08-31 21:11:12 -0700 | [diff] [blame] | 353 | |
| 354 | /* Notify the netvsc driver of the new device */ |
K. Y. Srinivasan | aae2398 | 2011-05-12 19:35:05 -0700 | [diff] [blame] | 355 | device_info.ring_size = ring_size; |
Haiyang Zhang | bdbad57 | 2011-05-23 09:03:49 -0700 | [diff] [blame] | 356 | ret = rndis_filter_device_add(dev, &device_info); |
Greg Kroah-Hartman | df2fff2 | 2009-08-31 21:11:12 -0700 | [diff] [blame] | 357 | if (ret != 0) { |
| 358 | free_netdev(net); |
K. Y. Srinivasan | 9efd21e | 2011-04-29 13:45:10 -0700 | [diff] [blame] | 359 | dev_set_drvdata(&dev->device, NULL); |
Greg Kroah-Hartman | df2fff2 | 2009-08-31 21:11:12 -0700 | [diff] [blame] | 360 | |
Hank Janssen | eb335bc | 2011-03-29 13:58:48 -0700 | [diff] [blame] | 361 | netdev_err(net, "unable to add netvsc device (ret %d)\n", ret); |
Greg Kroah-Hartman | df2fff2 | 2009-08-31 21:11:12 -0700 | [diff] [blame] | 362 | return ret; |
| 363 | } |
| 364 | |
Haiyang Zhang | b1956a8 | 2011-05-23 09:03:45 -0700 | [diff] [blame] | 365 | netif_carrier_on(net); |
Greg Kroah-Hartman | df2fff2 | 2009-08-31 21:11:12 -0700 | [diff] [blame] | 366 | |
Haiyang Zhang | 72a2f5b | 2010-12-10 12:03:58 -0800 | [diff] [blame] | 367 | memcpy(net->dev_addr, device_info.mac_adr, ETH_ALEN); |
Greg Kroah-Hartman | df2fff2 | 2009-08-31 21:11:12 -0700 | [diff] [blame] | 368 | |
| 369 | net->netdev_ops = &device_ops; |
| 370 | |
Stephen Hemminger | 6048718 | 2010-05-04 09:58:55 -0700 | [diff] [blame] | 371 | /* TODO: Add GSO and Checksum offload */ |
Michał Mirosław | 877a344 | 2011-04-19 12:43:20 +0200 | [diff] [blame] | 372 | net->hw_features = NETIF_F_SG; |
Stephen Hemminger | 6048718 | 2010-05-04 09:58:55 -0700 | [diff] [blame] | 373 | net->features = NETIF_F_SG; |
| 374 | |
Stephen Hemminger | f82f4ad | 2010-05-04 09:58:57 -0700 | [diff] [blame] | 375 | SET_ETHTOOL_OPS(net, ðtool_ops); |
K. Y. Srinivasan | 9efd21e | 2011-04-29 13:45:10 -0700 | [diff] [blame] | 376 | SET_NETDEV_DEV(net, &dev->device); |
Greg Kroah-Hartman | df2fff2 | 2009-08-31 21:11:12 -0700 | [diff] [blame] | 377 | |
| 378 | ret = register_netdev(net); |
| 379 | if (ret != 0) { |
| 380 | /* Remove the device and release the resource */ |
K. Y. Srinivasan | 58de3fc | 2011-05-10 07:55:01 -0700 | [diff] [blame] | 381 | rndis_filter_device_remove(dev); |
Greg Kroah-Hartman | df2fff2 | 2009-08-31 21:11:12 -0700 | [diff] [blame] | 382 | free_netdev(net); |
| 383 | } |
| 384 | |
Greg Kroah-Hartman | df2fff2 | 2009-08-31 21:11:12 -0700 | [diff] [blame] | 385 | return ret; |
| 386 | } |
| 387 | |
K. Y. Srinivasan | 415b023 | 2011-04-29 13:45:12 -0700 | [diff] [blame] | 388 | static int netvsc_remove(struct hv_device *dev) |
Greg Kroah-Hartman | df2fff2 | 2009-08-31 21:11:12 -0700 | [diff] [blame] | 389 | { |
K. Y. Srinivasan | 415b023 | 2011-04-29 13:45:12 -0700 | [diff] [blame] | 390 | struct net_device *net = dev_get_drvdata(&dev->device); |
Haiyang Zhang | 122a5f6 | 2011-05-27 06:21:55 -0700 | [diff] [blame] | 391 | struct net_device_context *ndev_ctx; |
Greg Kroah-Hartman | df2fff2 | 2009-08-31 21:11:12 -0700 | [diff] [blame] | 392 | |
Greg Kroah-Hartman | df2fff2 | 2009-08-31 21:11:12 -0700 | [diff] [blame] | 393 | if (net == NULL) { |
K. Y. Srinivasan | 415b023 | 2011-04-29 13:45:12 -0700 | [diff] [blame] | 394 | dev_err(&dev->device, "No net device to remove\n"); |
Greg Kroah-Hartman | df2fff2 | 2009-08-31 21:11:12 -0700 | [diff] [blame] | 395 | return 0; |
| 396 | } |
| 397 | |
Haiyang Zhang | 122a5f6 | 2011-05-27 06:21:55 -0700 | [diff] [blame] | 398 | ndev_ctx = netdev_priv(net); |
| 399 | cancel_delayed_work_sync(&ndev_ctx->dwork); |
| 400 | |
Greg Kroah-Hartman | df2fff2 | 2009-08-31 21:11:12 -0700 | [diff] [blame] | 401 | /* Stop outbound asap */ |
| 402 | netif_stop_queue(net); |
Greg Kroah-Hartman | df2fff2 | 2009-08-31 21:11:12 -0700 | [diff] [blame] | 403 | |
| 404 | unregister_netdev(net); |
| 405 | |
| 406 | /* |
| 407 | * Call to the vsc driver to let it know that the device is being |
| 408 | * removed |
| 409 | */ |
Haiyang Zhang | df06bcf | 2011-05-23 09:03:47 -0700 | [diff] [blame] | 410 | rndis_filter_device_remove(dev); |
Greg Kroah-Hartman | df2fff2 | 2009-08-31 21:11:12 -0700 | [diff] [blame] | 411 | |
| 412 | free_netdev(net); |
Haiyang Zhang | df06bcf | 2011-05-23 09:03:47 -0700 | [diff] [blame] | 413 | return 0; |
Greg Kroah-Hartman | df2fff2 | 2009-08-31 21:11:12 -0700 | [diff] [blame] | 414 | } |
| 415 | |
K. Y. Srinivasan | 345c4cc | 2011-08-25 09:48:34 -0700 | [diff] [blame^] | 416 | static const struct hv_vmbus_device_id id_table[] = { |
| 417 | { |
| 418 | /* Network guid */ |
| 419 | .guid = { |
| 420 | 0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46, |
| 421 | 0x91, 0x3F, 0xF2, 0xD2, 0xF9, 0x65, 0xED, 0x0E |
| 422 | } |
| 423 | }, |
| 424 | { |
| 425 | .guid = { } |
| 426 | }, |
| 427 | }; |
| 428 | |
| 429 | MODULE_DEVICE_TABLE(vmbus, id_table); |
| 430 | |
K. Y. Srinivasan | f1542a6 | 2011-05-10 07:55:16 -0700 | [diff] [blame] | 431 | /* The one and only one */ |
K. Y. Srinivasan | fde0ef9 | 2011-05-12 19:35:08 -0700 | [diff] [blame] | 432 | static struct hv_driver netvsc_drv = { |
K. Y. Srinivasan | 345c4cc | 2011-08-25 09:48:34 -0700 | [diff] [blame^] | 433 | .id_table = id_table, |
K. Y. Srinivasan | fde0ef9 | 2011-05-12 19:35:08 -0700 | [diff] [blame] | 434 | .probe = netvsc_probe, |
| 435 | .remove = netvsc_remove, |
K. Y. Srinivasan | d489097 | 2011-05-10 07:55:17 -0700 | [diff] [blame] | 436 | }; |
K. Y. Srinivasan | f1542a6 | 2011-05-10 07:55:16 -0700 | [diff] [blame] | 437 | |
K. Y. Srinivasan | a9869c9 | 2011-05-12 19:35:17 -0700 | [diff] [blame] | 438 | static void __exit netvsc_drv_exit(void) |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 439 | { |
K. Y. Srinivasan | fde0ef9 | 2011-05-12 19:35:08 -0700 | [diff] [blame] | 440 | vmbus_child_driver_unregister(&netvsc_drv.driver); |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 441 | } |
| 442 | |
K. Y. Srinivasan | 4753ff6 | 2011-05-12 19:35:13 -0700 | [diff] [blame] | 443 | |
| 444 | static const struct dmi_system_id __initconst |
| 445 | hv_netvsc_dmi_table[] __maybe_unused = { |
| 446 | { |
| 447 | .ident = "Hyper-V", |
| 448 | .matches = { |
| 449 | DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"), |
| 450 | DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"), |
| 451 | DMI_MATCH(DMI_BOARD_NAME, "Virtual Machine"), |
| 452 | }, |
| 453 | }, |
| 454 | { }, |
| 455 | }; |
| 456 | MODULE_DEVICE_TABLE(dmi, hv_netvsc_dmi_table); |
| 457 | |
K. Y. Srinivasan | 1fde28c | 2011-05-12 19:35:16 -0700 | [diff] [blame] | 458 | static int __init netvsc_drv_init(void) |
Greg Kroah-Hartman | df2fff2 | 2009-08-31 21:11:12 -0700 | [diff] [blame] | 459 | { |
K. Y. Srinivasan | fde0ef9 | 2011-05-12 19:35:08 -0700 | [diff] [blame] | 460 | struct hv_driver *drv = &netvsc_drv; |
Greg Kroah-Hartman | df2fff2 | 2009-08-31 21:11:12 -0700 | [diff] [blame] | 461 | int ret; |
| 462 | |
K. Y. Srinivasan | bb546d0 | 2011-05-12 19:35:15 -0700 | [diff] [blame] | 463 | pr_info("initializing...."); |
| 464 | |
| 465 | if (!dmi_check_system(hv_netvsc_dmi_table)) |
| 466 | return -ENODEV; |
| 467 | |
| 468 | |
Greg Kroah-Hartman | df2fff2 | 2009-08-31 21:11:12 -0700 | [diff] [blame] | 469 | /* Callback to client driver to complete the initialization */ |
K. Y. Srinivasan | 073aad3 | 2011-05-12 19:35:14 -0700 | [diff] [blame] | 470 | netvsc_initialize(drv); |
Greg Kroah-Hartman | df2fff2 | 2009-08-31 21:11:12 -0700 | [diff] [blame] | 471 | |
K. Y. Srinivasan | fde0ef9 | 2011-05-12 19:35:08 -0700 | [diff] [blame] | 472 | drv->driver.name = drv->name; |
Greg Kroah-Hartman | df2fff2 | 2009-08-31 21:11:12 -0700 | [diff] [blame] | 473 | |
Greg Kroah-Hartman | df2fff2 | 2009-08-31 21:11:12 -0700 | [diff] [blame] | 474 | /* The driver belongs to vmbus */ |
K. Y. Srinivasan | 150f939 | 2011-03-07 13:32:31 -0800 | [diff] [blame] | 475 | ret = vmbus_child_driver_register(&drv->driver); |
Greg Kroah-Hartman | df2fff2 | 2009-08-31 21:11:12 -0700 | [diff] [blame] | 476 | |
Greg Kroah-Hartman | df2fff2 | 2009-08-31 21:11:12 -0700 | [diff] [blame] | 477 | return ret; |
| 478 | } |
| 479 | |
K. Y. Srinivasan | 06e719d | 2010-05-07 17:52:17 -0600 | [diff] [blame] | 480 | static const struct pci_device_id __initconst |
| 481 | hv_netvsc_pci_table[] __maybe_unused = { |
| 482 | { PCI_DEVICE(0x1414, 0x5353) }, /* VGA compatible controller */ |
| 483 | { 0 } |
| 484 | }; |
| 485 | MODULE_DEVICE_TABLE(pci, hv_netvsc_pci_table); |
| 486 | |
Hank Janssen | 26c14cc | 2010-02-11 23:02:42 +0000 | [diff] [blame] | 487 | MODULE_LICENSE("GPL"); |
| 488 | MODULE_VERSION(HV_DRV_VERSION); |
Stephen Hemminger | 7880fc5 | 2010-05-04 09:58:52 -0700 | [diff] [blame] | 489 | MODULE_DESCRIPTION("Microsoft Hyper-V network driver"); |
Hank Janssen | fceaf24 | 2009-07-13 15:34:54 -0700 | [diff] [blame] | 490 | |
K. Y. Srinivasan | 1fde28c | 2011-05-12 19:35:16 -0700 | [diff] [blame] | 491 | module_init(netvsc_drv_init); |
K. Y. Srinivasan | a9869c9 | 2011-05-12 19:35:17 -0700 | [diff] [blame] | 492 | module_exit(netvsc_drv_exit); |