Commit 860d7ef6 authored by David S. Miller's avatar David S. Miller

Merge branch 'hv_netvsc-races'

Vitaly Kuznetsov says:

====================
hv_netvsc: avoid races on mtu change/set channels

Changes since v1:
- Rebased to net-next [Haiyang Zhang]

Original description:

MTU change and set channels operations are implemented as netvsc device
re-creation destroying internal structures (struct net_device stays). This
is really unfortunate but there is no support from Hyper-V host to do it
in a different way. Such re-creation is unsurprisingly racy, Haiyang
reported a crash when netvsc_change_mtu() is racing with
netvsc_link_change() but I was able to identify additional races upon
investigation. Both netvsc_set_channels() and netvsc_change_mtu() race
against:
1) netvsc_link_change()
2) netvsc_remove()
3) netvsc_send()

To solve these issues without introducing new locks some refactoring is
required. We need to get rid of very complex link graph in all the
internal structures and avoid traveling through structures which are being
removed.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents da47b457 88098834
...@@ -158,7 +158,7 @@ enum rndis_device_state { ...@@ -158,7 +158,7 @@ enum rndis_device_state {
}; };
struct rndis_device { struct rndis_device {
struct netvsc_device *net_dev; struct net_device *ndev;
enum rndis_device_state state; enum rndis_device_state state;
bool link_state; bool link_state;
...@@ -202,7 +202,7 @@ int rndis_filter_receive(struct hv_device *dev, ...@@ -202,7 +202,7 @@ int rndis_filter_receive(struct hv_device *dev,
int rndis_filter_set_packet_filter(struct rndis_device *dev, u32 new_filter); int rndis_filter_set_packet_filter(struct rndis_device *dev, u32 new_filter);
int rndis_filter_set_device_mac(struct hv_device *hdev, char *mac); int rndis_filter_set_device_mac(struct hv_device *hdev, char *mac);
void netvsc_switch_datapath(struct netvsc_device *nv_dev, bool vf); void netvsc_switch_datapath(struct net_device *nv_dev, bool vf);
#define NVSP_INVALID_PROTOCOL_VERSION ((u32)0xFFFFFFFF) #define NVSP_INVALID_PROTOCOL_VERSION ((u32)0xFFFFFFFF)
...@@ -653,6 +653,8 @@ struct garp_wrk { ...@@ -653,6 +653,8 @@ struct garp_wrk {
struct net_device_context { struct net_device_context {
/* point back to our device context */ /* point back to our device context */
struct hv_device *device_ctx; struct hv_device *device_ctx;
/* netvsc_device */
struct netvsc_device *nvdev;
/* reconfigure work */ /* reconfigure work */
struct delayed_work dwork; struct delayed_work dwork;
/* last reconfig time */ /* last reconfig time */
...@@ -672,17 +674,17 @@ struct net_device_context { ...@@ -672,17 +674,17 @@ struct net_device_context {
/* Ethtool settings */ /* Ethtool settings */
u8 duplex; u8 duplex;
u32 speed; u32 speed;
/* the device is going away */
bool start_remove;
}; };
/* Per netvsc device */ /* Per netvsc device */
struct netvsc_device { struct netvsc_device {
struct hv_device *dev;
u32 nvsp_version; u32 nvsp_version;
atomic_t num_outstanding_sends; atomic_t num_outstanding_sends;
wait_queue_head_t wait_drain; wait_queue_head_t wait_drain;
bool start_remove;
bool destroy; bool destroy;
/* Receive buffer allocated by us but manages by NetVSP */ /* Receive buffer allocated by us but manages by NetVSP */
...@@ -708,8 +710,6 @@ struct netvsc_device { ...@@ -708,8 +710,6 @@ struct netvsc_device {
struct nvsp_message revoke_packet; struct nvsp_message revoke_packet;
/* unsigned char HwMacAddr[HW_MACADDR_LEN]; */ /* unsigned char HwMacAddr[HW_MACADDR_LEN]; */
struct net_device *ndev;
struct vmbus_channel *chn_table[VRSS_CHANNEL_MAX]; struct vmbus_channel *chn_table[VRSS_CHANNEL_MAX];
u32 send_table[VRSS_SEND_TAB_SIZE]; u32 send_table[VRSS_SEND_TAB_SIZE];
u32 max_chn; u32 max_chn;
...@@ -732,9 +732,6 @@ struct netvsc_device { ...@@ -732,9 +732,6 @@ struct netvsc_device {
u32 max_pkt; /* max number of pkt in one send, e.g. 8 */ u32 max_pkt; /* max number of pkt in one send, e.g. 8 */
u32 pkt_align; /* alignment bytes, e.g. 8 */ u32 pkt_align; /* alignment bytes, e.g. 8 */
/* The net device context */
struct net_device_context *nd_ctx;
/* 1: allocated, serial number is valid. 0: not allocated */ /* 1: allocated, serial number is valid. 0: not allocated */
u32 vf_alloc; u32 vf_alloc;
/* Serial number of the VF to team with */ /* Serial number of the VF to team with */
......
...@@ -37,10 +37,12 @@ ...@@ -37,10 +37,12 @@
* Switch the data path from the synthetic interface to the VF * Switch the data path from the synthetic interface to the VF
* interface. * interface.
*/ */
void netvsc_switch_datapath(struct netvsc_device *nv_dev, bool vf) void netvsc_switch_datapath(struct net_device *ndev, bool vf)
{ {
struct net_device_context *net_device_ctx = netdev_priv(ndev);
struct hv_device *dev = net_device_ctx->device_ctx;
struct netvsc_device *nv_dev = net_device_ctx->nvdev;
struct nvsp_message *init_pkt = &nv_dev->channel_init_pkt; struct nvsp_message *init_pkt = &nv_dev->channel_init_pkt;
struct hv_device *dev = nv_dev->dev;
memset(init_pkt, 0, sizeof(struct nvsp_message)); memset(init_pkt, 0, sizeof(struct nvsp_message));
init_pkt->hdr.msg_type = NVSP_MSG4_TYPE_SWITCH_DATA_PATH; init_pkt->hdr.msg_type = NVSP_MSG4_TYPE_SWITCH_DATA_PATH;
...@@ -58,10 +60,9 @@ void netvsc_switch_datapath(struct netvsc_device *nv_dev, bool vf) ...@@ -58,10 +60,9 @@ void netvsc_switch_datapath(struct netvsc_device *nv_dev, bool vf)
} }
static struct netvsc_device *alloc_net_device(struct hv_device *device) static struct netvsc_device *alloc_net_device(void)
{ {
struct netvsc_device *net_device; struct netvsc_device *net_device;
struct net_device *ndev = hv_get_drvdata(device);
net_device = kzalloc(sizeof(struct netvsc_device), GFP_KERNEL); net_device = kzalloc(sizeof(struct netvsc_device), GFP_KERNEL);
if (!net_device) if (!net_device)
...@@ -74,19 +75,15 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device) ...@@ -74,19 +75,15 @@ static struct netvsc_device *alloc_net_device(struct hv_device *device)
} }
init_waitqueue_head(&net_device->wait_drain); init_waitqueue_head(&net_device->wait_drain);
net_device->start_remove = false;
net_device->destroy = false; net_device->destroy = false;
atomic_set(&net_device->open_cnt, 0); atomic_set(&net_device->open_cnt, 0);
atomic_set(&net_device->vf_use_cnt, 0); atomic_set(&net_device->vf_use_cnt, 0);
net_device->dev = device;
net_device->ndev = ndev;
net_device->max_pkt = RNDIS_MAX_PKT_DEFAULT; net_device->max_pkt = RNDIS_MAX_PKT_DEFAULT;
net_device->pkt_align = RNDIS_PKT_ALIGN_DEFAULT; net_device->pkt_align = RNDIS_PKT_ALIGN_DEFAULT;
net_device->vf_netdev = NULL; net_device->vf_netdev = NULL;
net_device->vf_inject = false; net_device->vf_inject = false;
hv_set_drvdata(device, net_device);
return net_device; return net_device;
} }
...@@ -98,9 +95,10 @@ static void free_netvsc_device(struct netvsc_device *nvdev) ...@@ -98,9 +95,10 @@ static void free_netvsc_device(struct netvsc_device *nvdev)
static struct netvsc_device *get_outbound_net_device(struct hv_device *device) static struct netvsc_device *get_outbound_net_device(struct hv_device *device)
{ {
struct netvsc_device *net_device; struct net_device *ndev = hv_get_drvdata(device);
struct net_device_context *net_device_ctx = netdev_priv(ndev);
struct netvsc_device *net_device = net_device_ctx->nvdev;
net_device = hv_get_drvdata(device);
if (net_device && net_device->destroy) if (net_device && net_device->destroy)
net_device = NULL; net_device = NULL;
...@@ -109,9 +107,9 @@ static struct netvsc_device *get_outbound_net_device(struct hv_device *device) ...@@ -109,9 +107,9 @@ static struct netvsc_device *get_outbound_net_device(struct hv_device *device)
static struct netvsc_device *get_inbound_net_device(struct hv_device *device) static struct netvsc_device *get_inbound_net_device(struct hv_device *device)
{ {
struct netvsc_device *net_device; struct net_device *ndev = hv_get_drvdata(device);
struct net_device_context *net_device_ctx = netdev_priv(ndev);
net_device = hv_get_drvdata(device); struct netvsc_device *net_device = net_device_ctx->nvdev;
if (!net_device) if (!net_device)
goto get_in_err; goto get_in_err;
...@@ -125,11 +123,13 @@ static struct netvsc_device *get_inbound_net_device(struct hv_device *device) ...@@ -125,11 +123,13 @@ static struct netvsc_device *get_inbound_net_device(struct hv_device *device)
} }
static int netvsc_destroy_buf(struct netvsc_device *net_device) static int netvsc_destroy_buf(struct hv_device *device)
{ {
struct nvsp_message *revoke_packet; struct nvsp_message *revoke_packet;
int ret = 0; int ret = 0;
struct net_device *ndev = net_device->ndev; struct net_device *ndev = hv_get_drvdata(device);
struct net_device_context *net_device_ctx = netdev_priv(ndev);
struct netvsc_device *net_device = net_device_ctx->nvdev;
/* /*
* If we got a section count, it means we received a * If we got a section count, it means we received a
...@@ -147,7 +147,7 @@ static int netvsc_destroy_buf(struct netvsc_device *net_device) ...@@ -147,7 +147,7 @@ static int netvsc_destroy_buf(struct netvsc_device *net_device)
revoke_packet->msg.v1_msg. revoke_packet->msg.v1_msg.
revoke_recv_buf.id = NETVSC_RECEIVE_BUFFER_ID; revoke_recv_buf.id = NETVSC_RECEIVE_BUFFER_ID;
ret = vmbus_sendpacket(net_device->dev->channel, ret = vmbus_sendpacket(device->channel,
revoke_packet, revoke_packet,
sizeof(struct nvsp_message), sizeof(struct nvsp_message),
(unsigned long)revoke_packet, (unsigned long)revoke_packet,
...@@ -165,7 +165,7 @@ static int netvsc_destroy_buf(struct netvsc_device *net_device) ...@@ -165,7 +165,7 @@ static int netvsc_destroy_buf(struct netvsc_device *net_device)
/* Teardown the gpadl on the vsp end */ /* Teardown the gpadl on the vsp end */
if (net_device->recv_buf_gpadl_handle) { if (net_device->recv_buf_gpadl_handle) {
ret = vmbus_teardown_gpadl(net_device->dev->channel, ret = vmbus_teardown_gpadl(device->channel,
net_device->recv_buf_gpadl_handle); net_device->recv_buf_gpadl_handle);
/* If we failed here, we might as well return and have a leak /* If we failed here, we might as well return and have a leak
...@@ -207,7 +207,7 @@ static int netvsc_destroy_buf(struct netvsc_device *net_device) ...@@ -207,7 +207,7 @@ static int netvsc_destroy_buf(struct netvsc_device *net_device)
revoke_packet->msg.v1_msg.revoke_send_buf.id = revoke_packet->msg.v1_msg.revoke_send_buf.id =
NETVSC_SEND_BUFFER_ID; NETVSC_SEND_BUFFER_ID;
ret = vmbus_sendpacket(net_device->dev->channel, ret = vmbus_sendpacket(device->channel,
revoke_packet, revoke_packet,
sizeof(struct nvsp_message), sizeof(struct nvsp_message),
(unsigned long)revoke_packet, (unsigned long)revoke_packet,
...@@ -223,7 +223,7 @@ static int netvsc_destroy_buf(struct netvsc_device *net_device) ...@@ -223,7 +223,7 @@ static int netvsc_destroy_buf(struct netvsc_device *net_device)
} }
/* Teardown the gpadl on the vsp end */ /* Teardown the gpadl on the vsp end */
if (net_device->send_buf_gpadl_handle) { if (net_device->send_buf_gpadl_handle) {
ret = vmbus_teardown_gpadl(net_device->dev->channel, ret = vmbus_teardown_gpadl(device->channel,
net_device->send_buf_gpadl_handle); net_device->send_buf_gpadl_handle);
/* If we failed here, we might as well return and have a leak /* If we failed here, we might as well return and have a leak
...@@ -258,7 +258,7 @@ static int netvsc_init_buf(struct hv_device *device) ...@@ -258,7 +258,7 @@ static int netvsc_init_buf(struct hv_device *device)
net_device = get_outbound_net_device(device); net_device = get_outbound_net_device(device);
if (!net_device) if (!net_device)
return -ENODEV; return -ENODEV;
ndev = net_device->ndev; ndev = hv_get_drvdata(device);
node = cpu_to_node(device->channel->target_cpu); node = cpu_to_node(device->channel->target_cpu);
net_device->recv_buf = vzalloc_node(net_device->recv_buf_size, node); net_device->recv_buf = vzalloc_node(net_device->recv_buf_size, node);
...@@ -435,7 +435,7 @@ static int netvsc_init_buf(struct hv_device *device) ...@@ -435,7 +435,7 @@ static int netvsc_init_buf(struct hv_device *device)
goto exit; goto exit;
cleanup: cleanup:
netvsc_destroy_buf(net_device); netvsc_destroy_buf(device);
exit: exit:
return ret; return ret;
...@@ -448,6 +448,7 @@ static int negotiate_nvsp_ver(struct hv_device *device, ...@@ -448,6 +448,7 @@ static int negotiate_nvsp_ver(struct hv_device *device,
struct nvsp_message *init_packet, struct nvsp_message *init_packet,
u32 nvsp_ver) u32 nvsp_ver)
{ {
struct net_device *ndev = hv_get_drvdata(device);
int ret; int ret;
unsigned long t; unsigned long t;
...@@ -481,8 +482,7 @@ static int negotiate_nvsp_ver(struct hv_device *device, ...@@ -481,8 +482,7 @@ static int negotiate_nvsp_ver(struct hv_device *device,
/* NVSPv2 or later: Send NDIS config */ /* NVSPv2 or later: Send NDIS config */
memset(init_packet, 0, sizeof(struct nvsp_message)); memset(init_packet, 0, sizeof(struct nvsp_message));
init_packet->hdr.msg_type = NVSP_MSG2_TYPE_SEND_NDIS_CONFIG; init_packet->hdr.msg_type = NVSP_MSG2_TYPE_SEND_NDIS_CONFIG;
init_packet->msg.v2_msg.send_ndis_config.mtu = net_device->ndev->mtu + init_packet->msg.v2_msg.send_ndis_config.mtu = ndev->mtu + ETH_HLEN;
ETH_HLEN;
init_packet->msg.v2_msg.send_ndis_config.capability.ieee8021q = 1; init_packet->msg.v2_msg.send_ndis_config.capability.ieee8021q = 1;
if (nvsp_ver >= NVSP_PROTOCOL_VERSION_5) if (nvsp_ver >= NVSP_PROTOCOL_VERSION_5)
...@@ -502,7 +502,6 @@ static int netvsc_connect_vsp(struct hv_device *device) ...@@ -502,7 +502,6 @@ static int netvsc_connect_vsp(struct hv_device *device)
struct netvsc_device *net_device; struct netvsc_device *net_device;
struct nvsp_message *init_packet; struct nvsp_message *init_packet;
int ndis_version; int ndis_version;
struct net_device *ndev;
u32 ver_list[] = { NVSP_PROTOCOL_VERSION_1, NVSP_PROTOCOL_VERSION_2, u32 ver_list[] = { NVSP_PROTOCOL_VERSION_1, NVSP_PROTOCOL_VERSION_2,
NVSP_PROTOCOL_VERSION_4, NVSP_PROTOCOL_VERSION_5 }; NVSP_PROTOCOL_VERSION_4, NVSP_PROTOCOL_VERSION_5 };
int i, num_ver = 4; /* number of different NVSP versions */ int i, num_ver = 4; /* number of different NVSP versions */
...@@ -510,7 +509,6 @@ static int netvsc_connect_vsp(struct hv_device *device) ...@@ -510,7 +509,6 @@ static int netvsc_connect_vsp(struct hv_device *device)
net_device = get_outbound_net_device(device); net_device = get_outbound_net_device(device);
if (!net_device) if (!net_device)
return -ENODEV; return -ENODEV;
ndev = net_device->ndev;
init_packet = &net_device->channel_init_pkt; init_packet = &net_device->channel_init_pkt;
...@@ -566,9 +564,9 @@ static int netvsc_connect_vsp(struct hv_device *device) ...@@ -566,9 +564,9 @@ static int netvsc_connect_vsp(struct hv_device *device)
return ret; return ret;
} }
static void netvsc_disconnect_vsp(struct netvsc_device *net_device) static void netvsc_disconnect_vsp(struct hv_device *device)
{ {
netvsc_destroy_buf(net_device); netvsc_destroy_buf(device);
} }
/* /*
...@@ -576,24 +574,13 @@ static void netvsc_disconnect_vsp(struct netvsc_device *net_device) ...@@ -576,24 +574,13 @@ static void netvsc_disconnect_vsp(struct netvsc_device *net_device)
*/ */
int netvsc_device_remove(struct hv_device *device) int netvsc_device_remove(struct hv_device *device)
{ {
struct netvsc_device *net_device; struct net_device *ndev = hv_get_drvdata(device);
unsigned long flags; struct net_device_context *net_device_ctx = netdev_priv(ndev);
struct netvsc_device *net_device = net_device_ctx->nvdev;
net_device = hv_get_drvdata(device);
netvsc_disconnect_vsp(net_device);
/* netvsc_disconnect_vsp(device);
* Since we have already drained, we don't need to busy wait
* as was done in final_release_stor_device()
* Note that we cannot set the ext pointer to NULL until
* we have drained - to drain the outgoing packets, we need to
* allow incoming packets.
*/
spin_lock_irqsave(&device->channel->inbound_lock, flags); net_device_ctx->nvdev = NULL;
hv_set_drvdata(device, NULL);
spin_unlock_irqrestore(&device->channel->inbound_lock, flags);
/* /*
* At this point, no one should be accessing net_device * At this point, no one should be accessing net_device
...@@ -641,12 +628,11 @@ static void netvsc_send_completion(struct netvsc_device *net_device, ...@@ -641,12 +628,11 @@ static void netvsc_send_completion(struct netvsc_device *net_device,
{ {
struct nvsp_message *nvsp_packet; struct nvsp_message *nvsp_packet;
struct hv_netvsc_packet *nvsc_packet; struct hv_netvsc_packet *nvsc_packet;
struct net_device *ndev; struct net_device *ndev = hv_get_drvdata(device);
struct net_device_context *net_device_ctx = netdev_priv(ndev);
u32 send_index; u32 send_index;
struct sk_buff *skb; struct sk_buff *skb;
ndev = net_device->ndev;
nvsp_packet = (struct nvsp_message *)((unsigned long)packet + nvsp_packet = (struct nvsp_message *)((unsigned long)packet +
(packet->offset8 << 3)); (packet->offset8 << 3));
...@@ -691,7 +677,7 @@ static void netvsc_send_completion(struct netvsc_device *net_device, ...@@ -691,7 +677,7 @@ static void netvsc_send_completion(struct netvsc_device *net_device,
wake_up(&net_device->wait_drain); wake_up(&net_device->wait_drain);
if (netif_tx_queue_stopped(netdev_get_tx_queue(ndev, q_idx)) && if (netif_tx_queue_stopped(netdev_get_tx_queue(ndev, q_idx)) &&
!net_device->start_remove && !net_device_ctx->start_remove &&
(hv_ringbuf_avail_percent(&channel->outbound) > (hv_ringbuf_avail_percent(&channel->outbound) >
RING_AVAIL_PERCENT_HIWATER || queue_sends < 1)) RING_AVAIL_PERCENT_HIWATER || queue_sends < 1))
netif_tx_wake_queue(netdev_get_tx_queue( netif_tx_wake_queue(netdev_get_tx_queue(
...@@ -775,6 +761,7 @@ static u32 netvsc_copy_to_send_buf(struct netvsc_device *net_device, ...@@ -775,6 +761,7 @@ static u32 netvsc_copy_to_send_buf(struct netvsc_device *net_device,
} }
static inline int netvsc_send_pkt( static inline int netvsc_send_pkt(
struct hv_device *device,
struct hv_netvsc_packet *packet, struct hv_netvsc_packet *packet,
struct netvsc_device *net_device, struct netvsc_device *net_device,
struct hv_page_buffer **pb, struct hv_page_buffer **pb,
...@@ -783,7 +770,7 @@ static inline int netvsc_send_pkt( ...@@ -783,7 +770,7 @@ static inline int netvsc_send_pkt(
struct nvsp_message nvmsg; struct nvsp_message nvmsg;
u16 q_idx = packet->q_idx; u16 q_idx = packet->q_idx;
struct vmbus_channel *out_channel = net_device->chn_table[q_idx]; struct vmbus_channel *out_channel = net_device->chn_table[q_idx];
struct net_device *ndev = net_device->ndev; struct net_device *ndev = hv_get_drvdata(device);
u64 req_id; u64 req_id;
int ret; int ret;
struct hv_page_buffer *pgbuf; struct hv_page_buffer *pgbuf;
...@@ -978,7 +965,8 @@ int netvsc_send(struct hv_device *device, ...@@ -978,7 +965,8 @@ int netvsc_send(struct hv_device *device,
} }
if (msd_send) { if (msd_send) {
m_ret = netvsc_send_pkt(msd_send, net_device, NULL, msd_skb); m_ret = netvsc_send_pkt(device, msd_send, net_device,
NULL, msd_skb);
if (m_ret != 0) { if (m_ret != 0) {
netvsc_free_send_slot(net_device, netvsc_free_send_slot(net_device,
...@@ -989,7 +977,7 @@ int netvsc_send(struct hv_device *device, ...@@ -989,7 +977,7 @@ int netvsc_send(struct hv_device *device,
send_now: send_now:
if (cur_send) if (cur_send)
ret = netvsc_send_pkt(cur_send, net_device, pb, skb); ret = netvsc_send_pkt(device, cur_send, net_device, pb, skb);
if (ret != 0 && section_index != NETVSC_INVALID_INDEX) if (ret != 0 && section_index != NETVSC_INVALID_INDEX)
netvsc_free_send_slot(net_device, section_index); netvsc_free_send_slot(net_device, section_index);
...@@ -1005,9 +993,7 @@ static void netvsc_send_recv_completion(struct hv_device *device, ...@@ -1005,9 +993,7 @@ static void netvsc_send_recv_completion(struct hv_device *device,
struct nvsp_message recvcompMessage; struct nvsp_message recvcompMessage;
int retries = 0; int retries = 0;
int ret; int ret;
struct net_device *ndev; struct net_device *ndev = hv_get_drvdata(device);
ndev = net_device->ndev;
recvcompMessage.hdr.msg_type = recvcompMessage.hdr.msg_type =
NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE; NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE;
...@@ -1054,11 +1040,9 @@ static void netvsc_receive(struct netvsc_device *net_device, ...@@ -1054,11 +1040,9 @@ static void netvsc_receive(struct netvsc_device *net_device,
u32 status = NVSP_STAT_SUCCESS; u32 status = NVSP_STAT_SUCCESS;
int i; int i;
int count = 0; int count = 0;
struct net_device *ndev; struct net_device *ndev = hv_get_drvdata(device);
void *data; void *data;
ndev = net_device->ndev;
/* /*
* All inbound packets other than send completion should be xfer page * All inbound packets other than send completion should be xfer page
* packet * packet
...@@ -1114,14 +1098,13 @@ static void netvsc_send_table(struct hv_device *hdev, ...@@ -1114,14 +1098,13 @@ static void netvsc_send_table(struct hv_device *hdev,
struct nvsp_message *nvmsg) struct nvsp_message *nvmsg)
{ {
struct netvsc_device *nvscdev; struct netvsc_device *nvscdev;
struct net_device *ndev; struct net_device *ndev = hv_get_drvdata(hdev);
int i; int i;
u32 count, *tab; u32 count, *tab;
nvscdev = get_outbound_net_device(hdev); nvscdev = get_outbound_net_device(hdev);
if (!nvscdev) if (!nvscdev)
return; return;
ndev = nvscdev->ndev;
count = nvmsg->msg.v5_msg.send_table.count; count = nvmsg->msg.v5_msg.send_table.count;
if (count != VRSS_SEND_TAB_SIZE) { if (count != VRSS_SEND_TAB_SIZE) {
...@@ -1180,7 +1163,7 @@ void netvsc_channel_cb(void *context) ...@@ -1180,7 +1163,7 @@ void netvsc_channel_cb(void *context)
net_device = get_inbound_net_device(device); net_device = get_inbound_net_device(device);
if (!net_device) if (!net_device)
return; return;
ndev = net_device->ndev; ndev = hv_get_drvdata(device);
buffer = get_per_channel_state(channel); buffer = get_per_channel_state(channel);
do { do {
...@@ -1253,30 +1236,19 @@ void netvsc_channel_cb(void *context) ...@@ -1253,30 +1236,19 @@ void netvsc_channel_cb(void *context)
*/ */
int netvsc_device_add(struct hv_device *device, void *additional_info) int netvsc_device_add(struct hv_device *device, void *additional_info)
{ {
int ret = 0; int i, ret = 0;
int ring_size = int ring_size =
((struct netvsc_device_info *)additional_info)->ring_size; ((struct netvsc_device_info *)additional_info)->ring_size;
struct netvsc_device *net_device; struct netvsc_device *net_device;
struct net_device *ndev; struct net_device *ndev = hv_get_drvdata(device);
struct net_device_context *net_device_ctx = netdev_priv(ndev);
net_device = alloc_net_device(device); net_device = alloc_net_device();
if (!net_device) if (!net_device)
return -ENOMEM; return -ENOMEM;
net_device->ring_size = ring_size; net_device->ring_size = ring_size;
/*
* Coming into this function, struct net_device * is
* registered as the driver private data.
* In alloc_net_device(), we register struct netvsc_device *
* as the driver private data and stash away struct net_device *
* in struct netvsc_device *.
*/
ndev = net_device->ndev;
/* Add netvsc_device context to netvsc_device */
net_device->nd_ctx = netdev_priv(ndev);
/* Initialize the NetVSC channel extension */ /* Initialize the NetVSC channel extension */
init_completion(&net_device->channel_init_wait); init_completion(&net_device->channel_init_wait);
...@@ -1295,7 +1267,19 @@ int netvsc_device_add(struct hv_device *device, void *additional_info) ...@@ -1295,7 +1267,19 @@ int netvsc_device_add(struct hv_device *device, void *additional_info)
/* Channel is opened */ /* Channel is opened */
pr_info("hv_netvsc channel opened successfully\n"); pr_info("hv_netvsc channel opened successfully\n");
net_device->chn_table[0] = device->channel; /* If we're reopening the device we may have multiple queues, fill the
* chn_table with the default channel to use it before subchannels are
* opened.
*/
for (i = 0; i < VRSS_CHANNEL_MAX; i++)
net_device->chn_table[i] = device->channel;
/* Writing nvdev pointer unlocks netvsc_send(), make sure chn_table is
* populated.
*/
wmb();
net_device_ctx->nvdev = net_device;
/* Connect with the NetVsp */ /* Connect with the NetVsp */
ret = netvsc_connect_vsp(device); ret = netvsc_connect_vsp(device);
......
...@@ -67,18 +67,19 @@ static void do_set_multicast(struct work_struct *w) ...@@ -67,18 +67,19 @@ static void do_set_multicast(struct work_struct *w)
{ {
struct net_device_context *ndevctx = struct net_device_context *ndevctx =
container_of(w, struct net_device_context, work); container_of(w, struct net_device_context, work);
struct netvsc_device *nvdev; struct hv_device *device_obj = ndevctx->device_ctx;
struct net_device *ndev = hv_get_drvdata(device_obj);
struct netvsc_device *nvdev = ndevctx->nvdev;
struct rndis_device *rdev; struct rndis_device *rdev;
nvdev = hv_get_drvdata(ndevctx->device_ctx); if (!nvdev)
if (nvdev == NULL || nvdev->ndev == NULL)
return; return;
rdev = nvdev->extension; rdev = nvdev->extension;
if (rdev == NULL) if (rdev == NULL)
return; return;
if (nvdev->ndev->flags & IFF_PROMISC) if (ndev->flags & IFF_PROMISC)
rndis_filter_set_packet_filter(rdev, rndis_filter_set_packet_filter(rdev,
NDIS_PACKET_TYPE_PROMISCUOUS); NDIS_PACKET_TYPE_PROMISCUOUS);
else else
...@@ -99,7 +100,7 @@ static int netvsc_open(struct net_device *net) ...@@ -99,7 +100,7 @@ static int netvsc_open(struct net_device *net)
{ {
struct net_device_context *net_device_ctx = netdev_priv(net); struct net_device_context *net_device_ctx = netdev_priv(net);
struct hv_device *device_obj = net_device_ctx->device_ctx; struct hv_device *device_obj = net_device_ctx->device_ctx;
struct netvsc_device *nvdev; struct netvsc_device *nvdev = net_device_ctx->nvdev;
struct rndis_device *rdev; struct rndis_device *rdev;
int ret = 0; int ret = 0;
...@@ -114,7 +115,6 @@ static int netvsc_open(struct net_device *net) ...@@ -114,7 +115,6 @@ static int netvsc_open(struct net_device *net)
netif_tx_wake_all_queues(net); netif_tx_wake_all_queues(net);
nvdev = hv_get_drvdata(device_obj);
rdev = nvdev->extension; rdev = nvdev->extension;
if (!rdev->link_state) if (!rdev->link_state)
netif_carrier_on(net); netif_carrier_on(net);
...@@ -126,7 +126,7 @@ static int netvsc_close(struct net_device *net) ...@@ -126,7 +126,7 @@ static int netvsc_close(struct net_device *net)
{ {
struct net_device_context *net_device_ctx = netdev_priv(net); struct net_device_context *net_device_ctx = netdev_priv(net);
struct hv_device *device_obj = net_device_ctx->device_ctx; struct hv_device *device_obj = net_device_ctx->device_ctx;
struct netvsc_device *nvdev = hv_get_drvdata(device_obj); struct netvsc_device *nvdev = net_device_ctx->nvdev;
int ret; int ret;
u32 aread, awrite, i, msec = 10, retry = 0, retry_max = 20; u32 aread, awrite, i, msec = 10, retry = 0, retry_max = 20;
struct vmbus_channel *chn; struct vmbus_channel *chn;
...@@ -205,8 +205,7 @@ static u16 netvsc_select_queue(struct net_device *ndev, struct sk_buff *skb, ...@@ -205,8 +205,7 @@ static u16 netvsc_select_queue(struct net_device *ndev, struct sk_buff *skb,
void *accel_priv, select_queue_fallback_t fallback) void *accel_priv, select_queue_fallback_t fallback)
{ {
struct net_device_context *net_device_ctx = netdev_priv(ndev); struct net_device_context *net_device_ctx = netdev_priv(ndev);
struct hv_device *hdev = net_device_ctx->device_ctx; struct netvsc_device *nvsc_dev = net_device_ctx->nvdev;
struct netvsc_device *nvsc_dev = hv_get_drvdata(hdev);
u32 hash; u32 hash;
u16 q_idx = 0; u16 q_idx = 0;
...@@ -580,7 +579,6 @@ void netvsc_linkstatus_callback(struct hv_device *device_obj, ...@@ -580,7 +579,6 @@ void netvsc_linkstatus_callback(struct hv_device *device_obj,
struct rndis_indicate_status *indicate = &resp->msg.indicate_status; struct rndis_indicate_status *indicate = &resp->msg.indicate_status;
struct net_device *net; struct net_device *net;
struct net_device_context *ndev_ctx; struct net_device_context *ndev_ctx;
struct netvsc_device *net_device;
struct netvsc_reconfig *event; struct netvsc_reconfig *event;
unsigned long flags; unsigned long flags;
...@@ -590,8 +588,7 @@ void netvsc_linkstatus_callback(struct hv_device *device_obj, ...@@ -590,8 +588,7 @@ void netvsc_linkstatus_callback(struct hv_device *device_obj,
indicate->status != RNDIS_STATUS_MEDIA_DISCONNECT) indicate->status != RNDIS_STATUS_MEDIA_DISCONNECT)
return; return;
net_device = hv_get_drvdata(device_obj); net = hv_get_drvdata(device_obj);
net = net_device->ndev;
if (!net || net->reg_state != NETREG_REGISTERED) if (!net || net->reg_state != NETREG_REGISTERED)
return; return;
...@@ -659,16 +656,15 @@ int netvsc_recv_callback(struct hv_device *device_obj, ...@@ -659,16 +656,15 @@ int netvsc_recv_callback(struct hv_device *device_obj,
struct vmbus_channel *channel, struct vmbus_channel *channel,
u16 vlan_tci) u16 vlan_tci)
{ {
struct net_device *net; struct net_device *net = hv_get_drvdata(device_obj);
struct net_device_context *net_device_ctx; struct net_device_context *net_device_ctx = netdev_priv(net);
struct sk_buff *skb; struct sk_buff *skb;
struct sk_buff *vf_skb; struct sk_buff *vf_skb;
struct netvsc_stats *rx_stats; struct netvsc_stats *rx_stats;
struct netvsc_device *netvsc_dev = hv_get_drvdata(device_obj); struct netvsc_device *netvsc_dev = net_device_ctx->nvdev;
u32 bytes_recvd = packet->total_data_buflen; u32 bytes_recvd = packet->total_data_buflen;
int ret = 0; int ret = 0;
net = netvsc_dev->ndev;
if (!net || net->reg_state != NETREG_REGISTERED) if (!net || net->reg_state != NETREG_REGISTERED)
return NVSP_STAT_FAIL; return NVSP_STAT_FAIL;
...@@ -743,8 +739,7 @@ static void netvsc_get_channels(struct net_device *net, ...@@ -743,8 +739,7 @@ static void netvsc_get_channels(struct net_device *net,
struct ethtool_channels *channel) struct ethtool_channels *channel)
{ {
struct net_device_context *net_device_ctx = netdev_priv(net); struct net_device_context *net_device_ctx = netdev_priv(net);
struct hv_device *dev = net_device_ctx->device_ctx; struct netvsc_device *nvdev = net_device_ctx->nvdev;
struct netvsc_device *nvdev = hv_get_drvdata(dev);
if (nvdev) { if (nvdev) {
channel->max_combined = nvdev->max_chn; channel->max_combined = nvdev->max_chn;
...@@ -757,14 +752,14 @@ static int netvsc_set_channels(struct net_device *net, ...@@ -757,14 +752,14 @@ static int netvsc_set_channels(struct net_device *net,
{ {
struct net_device_context *net_device_ctx = netdev_priv(net); struct net_device_context *net_device_ctx = netdev_priv(net);
struct hv_device *dev = net_device_ctx->device_ctx; struct hv_device *dev = net_device_ctx->device_ctx;
struct netvsc_device *nvdev = hv_get_drvdata(dev); struct netvsc_device *nvdev = net_device_ctx->nvdev;
struct netvsc_device_info device_info; struct netvsc_device_info device_info;
u32 num_chn; u32 num_chn;
u32 max_chn; u32 max_chn;
int ret = 0; int ret = 0;
bool recovering = false; bool recovering = false;
if (!nvdev || nvdev->destroy) if (net_device_ctx->start_remove || !nvdev || nvdev->destroy)
return -ENODEV; return -ENODEV;
num_chn = nvdev->num_chn; num_chn = nvdev->num_chn;
...@@ -793,14 +788,11 @@ static int netvsc_set_channels(struct net_device *net, ...@@ -793,14 +788,11 @@ static int netvsc_set_channels(struct net_device *net,
goto out; goto out;
do_set: do_set:
nvdev->start_remove = true; net_device_ctx->start_remove = true;
rndis_filter_device_remove(dev); rndis_filter_device_remove(dev);
nvdev->num_chn = channels->combined_count; nvdev->num_chn = channels->combined_count;
net_device_ctx->device_ctx = dev;
hv_set_drvdata(dev, net);
memset(&device_info, 0, sizeof(device_info)); memset(&device_info, 0, sizeof(device_info));
device_info.num_chn = nvdev->num_chn; /* passed to RNDIS */ device_info.num_chn = nvdev->num_chn; /* passed to RNDIS */
device_info.ring_size = ring_size; device_info.ring_size = ring_size;
...@@ -815,7 +807,7 @@ static int netvsc_set_channels(struct net_device *net, ...@@ -815,7 +807,7 @@ static int netvsc_set_channels(struct net_device *net,
goto recover; goto recover;
} }
nvdev = hv_get_drvdata(dev); nvdev = net_device_ctx->nvdev;
ret = netif_set_real_num_tx_queues(net, nvdev->num_chn); ret = netif_set_real_num_tx_queues(net, nvdev->num_chn);
if (ret) { if (ret) {
...@@ -837,6 +829,9 @@ static int netvsc_set_channels(struct net_device *net, ...@@ -837,6 +829,9 @@ static int netvsc_set_channels(struct net_device *net,
out: out:
netvsc_open(net); netvsc_open(net);
net_device_ctx->start_remove = false;
/* We may have missed link change notifications */
schedule_delayed_work(&net_device_ctx->dwork, 0);
return ret; return ret;
...@@ -905,14 +900,14 @@ static int netvsc_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) ...@@ -905,14 +900,14 @@ static int netvsc_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
static int netvsc_change_mtu(struct net_device *ndev, int mtu) static int netvsc_change_mtu(struct net_device *ndev, int mtu)
{ {
struct net_device_context *ndevctx = netdev_priv(ndev); struct net_device_context *ndevctx = netdev_priv(ndev);
struct netvsc_device *nvdev = ndevctx->nvdev;
struct hv_device *hdev = ndevctx->device_ctx; struct hv_device *hdev = ndevctx->device_ctx;
struct netvsc_device *nvdev = hv_get_drvdata(hdev);
struct netvsc_device_info device_info; struct netvsc_device_info device_info;
int limit = ETH_DATA_LEN; int limit = ETH_DATA_LEN;
u32 num_chn; u32 num_chn;
int ret = 0; int ret = 0;
if (nvdev == NULL || nvdev->destroy) if (ndevctx->start_remove || !nvdev || nvdev->destroy)
return -ENODEV; return -ENODEV;
if (nvdev->nvsp_version >= NVSP_PROTOCOL_VERSION_2) if (nvdev->nvsp_version >= NVSP_PROTOCOL_VERSION_2)
...@@ -927,14 +922,11 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu) ...@@ -927,14 +922,11 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu)
num_chn = nvdev->num_chn; num_chn = nvdev->num_chn;
nvdev->start_remove = true; ndevctx->start_remove = true;
rndis_filter_device_remove(hdev); rndis_filter_device_remove(hdev);
ndev->mtu = mtu; ndev->mtu = mtu;
ndevctx->device_ctx = hdev;
hv_set_drvdata(hdev, ndev);
memset(&device_info, 0, sizeof(device_info)); memset(&device_info, 0, sizeof(device_info));
device_info.ring_size = ring_size; device_info.ring_size = ring_size;
device_info.num_chn = num_chn; device_info.num_chn = num_chn;
...@@ -943,6 +935,10 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu) ...@@ -943,6 +935,10 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu)
out: out:
netvsc_open(ndev); netvsc_open(ndev);
ndevctx->start_remove = false;
/* We may have missed link change notifications */
schedule_delayed_work(&ndevctx->dwork, 0);
return ret; return ret;
} }
...@@ -1055,18 +1051,22 @@ static const struct net_device_ops device_ops = { ...@@ -1055,18 +1051,22 @@ static const struct net_device_ops device_ops = {
*/ */
static void netvsc_link_change(struct work_struct *w) static void netvsc_link_change(struct work_struct *w)
{ {
struct net_device_context *ndev_ctx; struct net_device_context *ndev_ctx =
struct net_device *net; container_of(w, struct net_device_context, dwork.work);
struct hv_device *device_obj = ndev_ctx->device_ctx;
struct net_device *net = hv_get_drvdata(device_obj);
struct netvsc_device *net_device; struct netvsc_device *net_device;
struct rndis_device *rdev; struct rndis_device *rdev;
struct netvsc_reconfig *event = NULL; struct netvsc_reconfig *event = NULL;
bool notify = false, reschedule = false; bool notify = false, reschedule = false;
unsigned long flags, next_reconfig, delay; unsigned long flags, next_reconfig, delay;
ndev_ctx = container_of(w, struct net_device_context, dwork.work); rtnl_lock();
net_device = hv_get_drvdata(ndev_ctx->device_ctx); if (ndev_ctx->start_remove)
goto out_unlock;
net_device = ndev_ctx->nvdev;
rdev = net_device->extension; rdev = net_device->extension;
net = net_device->ndev;
next_reconfig = ndev_ctx->last_reconfig + LINKCHANGE_INT; next_reconfig = ndev_ctx->last_reconfig + LINKCHANGE_INT;
if (time_is_after_jiffies(next_reconfig)) { if (time_is_after_jiffies(next_reconfig)) {
...@@ -1077,7 +1077,7 @@ static void netvsc_link_change(struct work_struct *w) ...@@ -1077,7 +1077,7 @@ static void netvsc_link_change(struct work_struct *w)
delay = next_reconfig - jiffies; delay = next_reconfig - jiffies;
delay = delay < LINKCHANGE_INT ? delay : LINKCHANGE_INT; delay = delay < LINKCHANGE_INT ? delay : LINKCHANGE_INT;
schedule_delayed_work(&ndev_ctx->dwork, delay); schedule_delayed_work(&ndev_ctx->dwork, delay);
return; goto out_unlock;
} }
ndev_ctx->last_reconfig = jiffies; ndev_ctx->last_reconfig = jiffies;
...@@ -1091,9 +1091,7 @@ static void netvsc_link_change(struct work_struct *w) ...@@ -1091,9 +1091,7 @@ static void netvsc_link_change(struct work_struct *w)
spin_unlock_irqrestore(&ndev_ctx->lock, flags); spin_unlock_irqrestore(&ndev_ctx->lock, flags);
if (!event) if (!event)
return; goto out_unlock;
rtnl_lock();
switch (event->event) { switch (event->event) {
/* Only the following events are possible due to the check in /* Only the following events are possible due to the check in
...@@ -1142,6 +1140,11 @@ static void netvsc_link_change(struct work_struct *w) ...@@ -1142,6 +1140,11 @@ static void netvsc_link_change(struct work_struct *w)
*/ */
if (reschedule) if (reschedule)
schedule_delayed_work(&ndev_ctx->dwork, LINKCHANGE_INT); schedule_delayed_work(&ndev_ctx->dwork, LINKCHANGE_INT);
return;
out_unlock:
rtnl_unlock();
} }
static void netvsc_free_netdev(struct net_device *netdev) static void netvsc_free_netdev(struct net_device *netdev)
...@@ -1164,10 +1167,9 @@ static void netvsc_notify_peers(struct work_struct *wrk) ...@@ -1164,10 +1167,9 @@ static void netvsc_notify_peers(struct work_struct *wrk)
atomic_dec(&gwrk->netvsc_dev->vf_use_cnt); atomic_dec(&gwrk->netvsc_dev->vf_use_cnt);
} }
static struct netvsc_device *get_netvsc_device(char *mac) static struct net_device *get_netvsc_net_device(char *mac)
{ {
struct net_device *dev; struct net_device *dev, *found = NULL;
struct net_device_context *netvsc_ctx = NULL;
int rtnl_locked; int rtnl_locked;
rtnl_locked = rtnl_trylock(); rtnl_locked = rtnl_trylock();
...@@ -1176,21 +1178,20 @@ static struct netvsc_device *get_netvsc_device(char *mac) ...@@ -1176,21 +1178,20 @@ static struct netvsc_device *get_netvsc_device(char *mac)
if (memcmp(dev->dev_addr, mac, ETH_ALEN) == 0) { if (memcmp(dev->dev_addr, mac, ETH_ALEN) == 0) {
if (dev->netdev_ops != &device_ops) if (dev->netdev_ops != &device_ops)
continue; continue;
netvsc_ctx = netdev_priv(dev); found = dev;
break; break;
} }
} }
if (rtnl_locked) if (rtnl_locked)
rtnl_unlock(); rtnl_unlock();
if (netvsc_ctx == NULL) return found;
return NULL;
return hv_get_drvdata(netvsc_ctx->device_ctx);
} }
static int netvsc_register_vf(struct net_device *vf_netdev) static int netvsc_register_vf(struct net_device *vf_netdev)
{ {
struct net_device *ndev;
struct net_device_context *net_device_ctx;
struct netvsc_device *netvsc_dev; struct netvsc_device *netvsc_dev;
const struct ethtool_ops *eth_ops = vf_netdev->ethtool_ops; const struct ethtool_ops *eth_ops = vf_netdev->ethtool_ops;
...@@ -1202,11 +1203,16 @@ static int netvsc_register_vf(struct net_device *vf_netdev) ...@@ -1202,11 +1203,16 @@ static int netvsc_register_vf(struct net_device *vf_netdev)
* associate with the VF interface. If we don't find a matching * associate with the VF interface. If we don't find a matching
* synthetic interface, move on. * synthetic interface, move on.
*/ */
netvsc_dev = get_netvsc_device(vf_netdev->dev_addr); ndev = get_netvsc_net_device(vf_netdev->dev_addr);
if (!ndev)
return NOTIFY_DONE;
net_device_ctx = netdev_priv(ndev);
netvsc_dev = net_device_ctx->nvdev;
if (netvsc_dev == NULL) if (netvsc_dev == NULL)
return NOTIFY_DONE; return NOTIFY_DONE;
netdev_info(netvsc_dev->ndev, "VF registering: %s\n", vf_netdev->name); netdev_info(ndev, "VF registering: %s\n", vf_netdev->name);
/* /*
* Take a reference on the module. * Take a reference on the module.
*/ */
...@@ -1218,6 +1224,7 @@ static int netvsc_register_vf(struct net_device *vf_netdev) ...@@ -1218,6 +1224,7 @@ static int netvsc_register_vf(struct net_device *vf_netdev)
static int netvsc_vf_up(struct net_device *vf_netdev) static int netvsc_vf_up(struct net_device *vf_netdev)
{ {
struct net_device *ndev;
struct netvsc_device *netvsc_dev; struct netvsc_device *netvsc_dev;
const struct ethtool_ops *eth_ops = vf_netdev->ethtool_ops; const struct ethtool_ops *eth_ops = vf_netdev->ethtool_ops;
struct net_device_context *net_device_ctx; struct net_device_context *net_device_ctx;
...@@ -1225,13 +1232,17 @@ static int netvsc_vf_up(struct net_device *vf_netdev) ...@@ -1225,13 +1232,17 @@ static int netvsc_vf_up(struct net_device *vf_netdev)
if (eth_ops == &ethtool_ops) if (eth_ops == &ethtool_ops)
return NOTIFY_DONE; return NOTIFY_DONE;
netvsc_dev = get_netvsc_device(vf_netdev->dev_addr); ndev = get_netvsc_net_device(vf_netdev->dev_addr);
if (!ndev)
return NOTIFY_DONE;
net_device_ctx = netdev_priv(ndev);
netvsc_dev = net_device_ctx->nvdev;
if ((netvsc_dev == NULL) || (netvsc_dev->vf_netdev == NULL)) if ((netvsc_dev == NULL) || (netvsc_dev->vf_netdev == NULL))
return NOTIFY_DONE; return NOTIFY_DONE;
netdev_info(netvsc_dev->ndev, "VF up: %s\n", vf_netdev->name); netdev_info(ndev, "VF up: %s\n", vf_netdev->name);
net_device_ctx = netdev_priv(netvsc_dev->ndev);
netvsc_dev->vf_inject = true; netvsc_dev->vf_inject = true;
/* /*
...@@ -1242,11 +1253,10 @@ static int netvsc_vf_up(struct net_device *vf_netdev) ...@@ -1242,11 +1253,10 @@ static int netvsc_vf_up(struct net_device *vf_netdev)
/* /*
* notify the host to switch the data path. * notify the host to switch the data path.
*/ */
netvsc_switch_datapath(netvsc_dev, true); netvsc_switch_datapath(ndev, true);
netdev_info(netvsc_dev->ndev, "Data path switched to VF: %s\n", netdev_info(ndev, "Data path switched to VF: %s\n", vf_netdev->name);
vf_netdev->name);
netif_carrier_off(netvsc_dev->ndev); netif_carrier_off(ndev);
/* /*
* Now notify peers. We are scheduling work to * Now notify peers. We are scheduling work to
...@@ -1264,6 +1274,7 @@ static int netvsc_vf_up(struct net_device *vf_netdev) ...@@ -1264,6 +1274,7 @@ static int netvsc_vf_up(struct net_device *vf_netdev)
static int netvsc_vf_down(struct net_device *vf_netdev) static int netvsc_vf_down(struct net_device *vf_netdev)
{ {
struct net_device *ndev;
struct netvsc_device *netvsc_dev; struct netvsc_device *netvsc_dev;
struct net_device_context *net_device_ctx; struct net_device_context *net_device_ctx;
const struct ethtool_ops *eth_ops = vf_netdev->ethtool_ops; const struct ethtool_ops *eth_ops = vf_netdev->ethtool_ops;
...@@ -1271,13 +1282,17 @@ static int netvsc_vf_down(struct net_device *vf_netdev) ...@@ -1271,13 +1282,17 @@ static int netvsc_vf_down(struct net_device *vf_netdev)
if (eth_ops == &ethtool_ops) if (eth_ops == &ethtool_ops)
return NOTIFY_DONE; return NOTIFY_DONE;
netvsc_dev = get_netvsc_device(vf_netdev->dev_addr); ndev = get_netvsc_net_device(vf_netdev->dev_addr);
if (!ndev)
return NOTIFY_DONE;
net_device_ctx = netdev_priv(ndev);
netvsc_dev = net_device_ctx->nvdev;
if ((netvsc_dev == NULL) || (netvsc_dev->vf_netdev == NULL)) if ((netvsc_dev == NULL) || (netvsc_dev->vf_netdev == NULL))
return NOTIFY_DONE; return NOTIFY_DONE;
netdev_info(netvsc_dev->ndev, "VF down: %s\n", vf_netdev->name); netdev_info(ndev, "VF down: %s\n", vf_netdev->name);
net_device_ctx = netdev_priv(netvsc_dev->ndev);
netvsc_dev->vf_inject = false; netvsc_dev->vf_inject = false;
/* /*
* Wait for currently active users to * Wait for currently active users to
...@@ -1286,16 +1301,15 @@ static int netvsc_vf_down(struct net_device *vf_netdev) ...@@ -1286,16 +1301,15 @@ static int netvsc_vf_down(struct net_device *vf_netdev)
while (atomic_read(&netvsc_dev->vf_use_cnt) != 0) while (atomic_read(&netvsc_dev->vf_use_cnt) != 0)
udelay(50); udelay(50);
netvsc_switch_datapath(netvsc_dev, false); netvsc_switch_datapath(ndev, false);
netdev_info(netvsc_dev->ndev, "Data path switched from VF: %s\n", netdev_info(ndev, "Data path switched from VF: %s\n", vf_netdev->name);
vf_netdev->name);
rndis_filter_close(net_device_ctx->device_ctx); rndis_filter_close(net_device_ctx->device_ctx);
netif_carrier_on(netvsc_dev->ndev); netif_carrier_on(ndev);
/* /*
* Notify peers. * Notify peers.
*/ */
atomic_inc(&netvsc_dev->vf_use_cnt); atomic_inc(&netvsc_dev->vf_use_cnt);
net_device_ctx->gwrk.netdev = netvsc_dev->ndev; net_device_ctx->gwrk.netdev = ndev;
net_device_ctx->gwrk.netvsc_dev = netvsc_dev; net_device_ctx->gwrk.netvsc_dev = netvsc_dev;
schedule_work(&net_device_ctx->gwrk.dwrk); schedule_work(&net_device_ctx->gwrk.dwrk);
...@@ -1305,17 +1319,23 @@ static int netvsc_vf_down(struct net_device *vf_netdev) ...@@ -1305,17 +1319,23 @@ static int netvsc_vf_down(struct net_device *vf_netdev)
static int netvsc_unregister_vf(struct net_device *vf_netdev) static int netvsc_unregister_vf(struct net_device *vf_netdev)
{ {
struct net_device *ndev;
struct netvsc_device *netvsc_dev; struct netvsc_device *netvsc_dev;
const struct ethtool_ops *eth_ops = vf_netdev->ethtool_ops; const struct ethtool_ops *eth_ops = vf_netdev->ethtool_ops;
struct net_device_context *net_device_ctx;
if (eth_ops == &ethtool_ops) if (eth_ops == &ethtool_ops)
return NOTIFY_DONE; return NOTIFY_DONE;
netvsc_dev = get_netvsc_device(vf_netdev->dev_addr); ndev = get_netvsc_net_device(vf_netdev->dev_addr);
if (!ndev)
return NOTIFY_DONE;
net_device_ctx = netdev_priv(ndev);
netvsc_dev = net_device_ctx->nvdev;
if (netvsc_dev == NULL) if (netvsc_dev == NULL)
return NOTIFY_DONE; return NOTIFY_DONE;
netdev_info(netvsc_dev->ndev, "VF unregistering: %s\n", netdev_info(ndev, "VF unregistering: %s\n", vf_netdev->name);
vf_netdev->name);
netvsc_dev->vf_netdev = NULL; netvsc_dev->vf_netdev = NULL;
module_put(THIS_MODULE); module_put(THIS_MODULE);
...@@ -1358,6 +1378,9 @@ static int netvsc_probe(struct hv_device *dev, ...@@ -1358,6 +1378,9 @@ static int netvsc_probe(struct hv_device *dev,
} }
hv_set_drvdata(dev, net); hv_set_drvdata(dev, net);
net_device_ctx->start_remove = false;
INIT_DELAYED_WORK(&net_device_ctx->dwork, netvsc_link_change); INIT_DELAYED_WORK(&net_device_ctx->dwork, netvsc_link_change);
INIT_WORK(&net_device_ctx->work, do_set_multicast); INIT_WORK(&net_device_ctx->work, do_set_multicast);
INIT_WORK(&net_device_ctx->gwrk.dwrk, netvsc_notify_peers); INIT_WORK(&net_device_ctx->gwrk.dwrk, netvsc_notify_peers);
...@@ -1389,7 +1412,7 @@ static int netvsc_probe(struct hv_device *dev, ...@@ -1389,7 +1412,7 @@ static int netvsc_probe(struct hv_device *dev,
} }
memcpy(net->dev_addr, device_info.mac_adr, ETH_ALEN); memcpy(net->dev_addr, device_info.mac_adr, ETH_ALEN);
nvdev = hv_get_drvdata(dev); nvdev = net_device_ctx->nvdev;
netif_set_real_num_tx_queues(net, nvdev->num_chn); netif_set_real_num_tx_queues(net, nvdev->num_chn);
netif_set_real_num_rx_queues(net, nvdev->num_chn); netif_set_real_num_rx_queues(net, nvdev->num_chn);
...@@ -1411,17 +1434,24 @@ static int netvsc_remove(struct hv_device *dev) ...@@ -1411,17 +1434,24 @@ static int netvsc_remove(struct hv_device *dev)
struct net_device_context *ndev_ctx; struct net_device_context *ndev_ctx;
struct netvsc_device *net_device; struct netvsc_device *net_device;
net_device = hv_get_drvdata(dev); net = hv_get_drvdata(dev);
net = net_device->ndev;
if (net == NULL) { if (net == NULL) {
dev_err(&dev->device, "No net device to remove\n"); dev_err(&dev->device, "No net device to remove\n");
return 0; return 0;
} }
net_device->start_remove = true;
ndev_ctx = netdev_priv(net); ndev_ctx = netdev_priv(net);
net_device = ndev_ctx->nvdev;
/* Avoid racing with netvsc_change_mtu()/netvsc_set_channels()
* removing the device.
*/
rtnl_lock();
ndev_ctx->start_remove = true;
rtnl_unlock();
cancel_delayed_work_sync(&ndev_ctx->dwork); cancel_delayed_work_sync(&ndev_ctx->dwork);
cancel_work_sync(&ndev_ctx->work); cancel_work_sync(&ndev_ctx->work);
...@@ -1436,6 +1466,8 @@ static int netvsc_remove(struct hv_device *dev) ...@@ -1436,6 +1466,8 @@ static int netvsc_remove(struct hv_device *dev)
*/ */
rndis_filter_device_remove(dev); rndis_filter_device_remove(dev);
hv_set_drvdata(dev, NULL);
netvsc_free_netdev(net); netvsc_free_netdev(net);
return 0; return 0;
} }
......
...@@ -126,11 +126,7 @@ static void put_rndis_request(struct rndis_device *dev, ...@@ -126,11 +126,7 @@ static void put_rndis_request(struct rndis_device *dev,
static void dump_rndis_message(struct hv_device *hv_dev, static void dump_rndis_message(struct hv_device *hv_dev,
struct rndis_message *rndis_msg) struct rndis_message *rndis_msg)
{ {
struct net_device *netdev; struct net_device *netdev = hv_get_drvdata(hv_dev);
struct netvsc_device *net_device;
net_device = hv_get_drvdata(hv_dev);
netdev = net_device->ndev;
switch (rndis_msg->ndis_msg_type) { switch (rndis_msg->ndis_msg_type) {
case RNDIS_MSG_PACKET: case RNDIS_MSG_PACKET:
...@@ -211,6 +207,7 @@ static int rndis_filter_send_request(struct rndis_device *dev, ...@@ -211,6 +207,7 @@ static int rndis_filter_send_request(struct rndis_device *dev,
struct hv_netvsc_packet *packet; struct hv_netvsc_packet *packet;
struct hv_page_buffer page_buf[2]; struct hv_page_buffer page_buf[2];
struct hv_page_buffer *pb = page_buf; struct hv_page_buffer *pb = page_buf;
struct net_device_context *net_device_ctx = netdev_priv(dev->ndev);
/* Setup the packet to send it */ /* Setup the packet to send it */
packet = &req->pkt; packet = &req->pkt;
...@@ -236,7 +233,7 @@ static int rndis_filter_send_request(struct rndis_device *dev, ...@@ -236,7 +233,7 @@ static int rndis_filter_send_request(struct rndis_device *dev,
pb[0].len; pb[0].len;
} }
ret = netvsc_send(dev->net_dev->dev, packet, NULL, &pb, NULL); ret = netvsc_send(net_device_ctx->device_ctx, packet, NULL, &pb, NULL);
return ret; return ret;
} }
...@@ -262,9 +259,7 @@ static void rndis_filter_receive_response(struct rndis_device *dev, ...@@ -262,9 +259,7 @@ static void rndis_filter_receive_response(struct rndis_device *dev,
struct rndis_request *request = NULL; struct rndis_request *request = NULL;
bool found = false; bool found = false;
unsigned long flags; unsigned long flags;
struct net_device *ndev; struct net_device *ndev = dev->ndev;
ndev = dev->net_dev->ndev;
spin_lock_irqsave(&dev->request_lock, flags); spin_lock_irqsave(&dev->request_lock, flags);
list_for_each_entry(request, &dev->req_list, list_ent) { list_for_each_entry(request, &dev->req_list, list_ent) {
...@@ -355,6 +350,7 @@ static int rndis_filter_receive_data(struct rndis_device *dev, ...@@ -355,6 +350,7 @@ static int rndis_filter_receive_data(struct rndis_device *dev,
struct ndis_pkt_8021q_info *vlan; struct ndis_pkt_8021q_info *vlan;
struct ndis_tcp_ip_checksum_info *csum_info; struct ndis_tcp_ip_checksum_info *csum_info;
u16 vlan_tci = 0; u16 vlan_tci = 0;
struct net_device_context *net_device_ctx = netdev_priv(dev->ndev);
rndis_pkt = &msg->msg.pkt; rndis_pkt = &msg->msg.pkt;
...@@ -368,7 +364,7 @@ static int rndis_filter_receive_data(struct rndis_device *dev, ...@@ -368,7 +364,7 @@ static int rndis_filter_receive_data(struct rndis_device *dev,
* should be the data packet size plus the trailer padding size * should be the data packet size plus the trailer padding size
*/ */
if (pkt->total_data_buflen < rndis_pkt->data_len) { if (pkt->total_data_buflen < rndis_pkt->data_len) {
netdev_err(dev->net_dev->ndev, "rndis message buffer " netdev_err(dev->ndev, "rndis message buffer "
"overflow detected (got %u, min %u)" "overflow detected (got %u, min %u)"
"...dropping this message!\n", "...dropping this message!\n",
pkt->total_data_buflen, rndis_pkt->data_len); pkt->total_data_buflen, rndis_pkt->data_len);
...@@ -390,7 +386,7 @@ static int rndis_filter_receive_data(struct rndis_device *dev, ...@@ -390,7 +386,7 @@ static int rndis_filter_receive_data(struct rndis_device *dev,
} }
csum_info = rndis_get_ppi(rndis_pkt, TCPIP_CHKSUM_PKTINFO); csum_info = rndis_get_ppi(rndis_pkt, TCPIP_CHKSUM_PKTINFO);
return netvsc_recv_callback(dev->net_dev->dev, pkt, data, return netvsc_recv_callback(net_device_ctx->device_ctx, pkt, data,
csum_info, channel, vlan_tci); csum_info, channel, vlan_tci);
} }
...@@ -399,10 +395,11 @@ int rndis_filter_receive(struct hv_device *dev, ...@@ -399,10 +395,11 @@ int rndis_filter_receive(struct hv_device *dev,
void **data, void **data,
struct vmbus_channel *channel) struct vmbus_channel *channel)
{ {
struct netvsc_device *net_dev = hv_get_drvdata(dev); struct net_device *ndev = hv_get_drvdata(dev);
struct net_device_context *net_device_ctx = netdev_priv(ndev);
struct netvsc_device *net_dev = net_device_ctx->nvdev;
struct rndis_device *rndis_dev; struct rndis_device *rndis_dev;
struct rndis_message *rndis_msg; struct rndis_message *rndis_msg;
struct net_device *ndev;
int ret = 0; int ret = 0;
if (!net_dev) { if (!net_dev) {
...@@ -410,8 +407,6 @@ int rndis_filter_receive(struct hv_device *dev, ...@@ -410,8 +407,6 @@ int rndis_filter_receive(struct hv_device *dev,
goto exit; goto exit;
} }
ndev = net_dev->ndev;
/* Make sure the rndis device state is initialized */ /* Make sure the rndis device state is initialized */
if (!net_dev->extension) { if (!net_dev->extension) {
netdev_err(ndev, "got rndis message but no rndis device - " netdev_err(ndev, "got rndis message but no rndis device - "
...@@ -430,7 +425,7 @@ int rndis_filter_receive(struct hv_device *dev, ...@@ -430,7 +425,7 @@ int rndis_filter_receive(struct hv_device *dev,
rndis_msg = *data; rndis_msg = *data;
if (netif_msg_rx_err(net_dev->nd_ctx)) if (netif_msg_rx_err(net_device_ctx))
dump_rndis_message(dev, rndis_msg); dump_rndis_message(dev, rndis_msg);
switch (rndis_msg->ndis_msg_type) { switch (rndis_msg->ndis_msg_type) {
...@@ -550,9 +545,10 @@ static int rndis_filter_query_device_mac(struct rndis_device *dev) ...@@ -550,9 +545,10 @@ static int rndis_filter_query_device_mac(struct rndis_device *dev)
int rndis_filter_set_device_mac(struct hv_device *hdev, char *mac) int rndis_filter_set_device_mac(struct hv_device *hdev, char *mac)
{ {
struct netvsc_device *nvdev = hv_get_drvdata(hdev); struct net_device *ndev = hv_get_drvdata(hdev);
struct net_device_context *net_device_ctx = netdev_priv(ndev);
struct netvsc_device *nvdev = net_device_ctx->nvdev;
struct rndis_device *rdev = nvdev->extension; struct rndis_device *rdev = nvdev->extension;
struct net_device *ndev = nvdev->ndev;
struct rndis_request *request; struct rndis_request *request;
struct rndis_set_request *set; struct rndis_set_request *set;
struct rndis_config_parameter_info *cpi; struct rndis_config_parameter_info *cpi;
...@@ -629,9 +625,10 @@ static int ...@@ -629,9 +625,10 @@ static int
rndis_filter_set_offload_params(struct hv_device *hdev, rndis_filter_set_offload_params(struct hv_device *hdev,
struct ndis_offload_params *req_offloads) struct ndis_offload_params *req_offloads)
{ {
struct netvsc_device *nvdev = hv_get_drvdata(hdev); struct net_device *ndev = hv_get_drvdata(hdev);
struct net_device_context *net_device_ctx = netdev_priv(ndev);
struct netvsc_device *nvdev = net_device_ctx->nvdev;
struct rndis_device *rdev = nvdev->extension; struct rndis_device *rdev = nvdev->extension;
struct net_device *ndev = nvdev->ndev;
struct rndis_request *request; struct rndis_request *request;
struct rndis_set_request *set; struct rndis_set_request *set;
struct ndis_offload_params *offload_params; struct ndis_offload_params *offload_params;
...@@ -703,7 +700,7 @@ u8 netvsc_hash_key[HASH_KEYLEN] = { ...@@ -703,7 +700,7 @@ u8 netvsc_hash_key[HASH_KEYLEN] = {
static int rndis_filter_set_rss_param(struct rndis_device *rdev, int num_queue) static int rndis_filter_set_rss_param(struct rndis_device *rdev, int num_queue)
{ {
struct net_device *ndev = rdev->net_dev->ndev; struct net_device *ndev = rdev->ndev;
struct rndis_request *request; struct rndis_request *request;
struct rndis_set_request *set; struct rndis_set_request *set;
struct rndis_set_complete *set_complete; struct rndis_set_complete *set_complete;
...@@ -799,9 +796,7 @@ int rndis_filter_set_packet_filter(struct rndis_device *dev, u32 new_filter) ...@@ -799,9 +796,7 @@ int rndis_filter_set_packet_filter(struct rndis_device *dev, u32 new_filter)
u32 status; u32 status;
int ret; int ret;
unsigned long t; unsigned long t;
struct net_device *ndev; struct net_device *ndev = dev->ndev;
ndev = dev->net_dev->ndev;
request = get_rndis_request(dev, RNDIS_MSG_SET, request = get_rndis_request(dev, RNDIS_MSG_SET,
RNDIS_MESSAGE_SIZE(struct rndis_set_request) + RNDIS_MESSAGE_SIZE(struct rndis_set_request) +
...@@ -856,7 +851,8 @@ static int rndis_filter_init_device(struct rndis_device *dev) ...@@ -856,7 +851,8 @@ static int rndis_filter_init_device(struct rndis_device *dev)
u32 status; u32 status;
int ret; int ret;
unsigned long t; unsigned long t;
struct netvsc_device *nvdev = dev->net_dev; struct net_device_context *net_device_ctx = netdev_priv(dev->ndev);
struct netvsc_device *nvdev = net_device_ctx->nvdev;
request = get_rndis_request(dev, RNDIS_MSG_INIT, request = get_rndis_request(dev, RNDIS_MSG_INIT,
RNDIS_MESSAGE_SIZE(struct rndis_initialize_request)); RNDIS_MESSAGE_SIZE(struct rndis_initialize_request));
...@@ -879,7 +875,6 @@ static int rndis_filter_init_device(struct rndis_device *dev) ...@@ -879,7 +875,6 @@ static int rndis_filter_init_device(struct rndis_device *dev)
goto cleanup; goto cleanup;
} }
t = wait_for_completion_timeout(&request->wait_event, 5*HZ); t = wait_for_completion_timeout(&request->wait_event, 5*HZ);
if (t == 0) { if (t == 0) {
...@@ -910,8 +905,9 @@ static void rndis_filter_halt_device(struct rndis_device *dev) ...@@ -910,8 +905,9 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
{ {
struct rndis_request *request; struct rndis_request *request;
struct rndis_halt_request *halt; struct rndis_halt_request *halt;
struct netvsc_device *nvdev = dev->net_dev; struct net_device_context *net_device_ctx = netdev_priv(dev->ndev);
struct hv_device *hdev = nvdev->dev; struct netvsc_device *nvdev = net_device_ctx->nvdev;
struct hv_device *hdev = net_device_ctx->device_ctx;
ulong flags; ulong flags;
/* Attempt to do a rndis device halt */ /* Attempt to do a rndis device halt */
...@@ -979,13 +975,14 @@ static int rndis_filter_close_device(struct rndis_device *dev) ...@@ -979,13 +975,14 @@ static int rndis_filter_close_device(struct rndis_device *dev)
static void netvsc_sc_open(struct vmbus_channel *new_sc) static void netvsc_sc_open(struct vmbus_channel *new_sc)
{ {
struct netvsc_device *nvscdev; struct net_device *ndev =
hv_get_drvdata(new_sc->primary_channel->device_obj);
struct net_device_context *net_device_ctx = netdev_priv(ndev);
struct netvsc_device *nvscdev = net_device_ctx->nvdev;
u16 chn_index = new_sc->offermsg.offer.sub_channel_index; u16 chn_index = new_sc->offermsg.offer.sub_channel_index;
int ret; int ret;
unsigned long flags; unsigned long flags;
nvscdev = hv_get_drvdata(new_sc->primary_channel->device_obj);
if (chn_index >= nvscdev->num_chn) if (chn_index >= nvscdev->num_chn)
return; return;
...@@ -1010,6 +1007,8 @@ int rndis_filter_device_add(struct hv_device *dev, ...@@ -1010,6 +1007,8 @@ int rndis_filter_device_add(struct hv_device *dev,
void *additional_info) void *additional_info)
{ {
int ret; int ret;
struct net_device *net = hv_get_drvdata(dev);
struct net_device_context *net_device_ctx = netdev_priv(net);
struct netvsc_device *net_device; struct netvsc_device *net_device;
struct rndis_device *rndis_device; struct rndis_device *rndis_device;
struct netvsc_device_info *device_info = additional_info; struct netvsc_device_info *device_info = additional_info;
...@@ -1040,16 +1039,15 @@ int rndis_filter_device_add(struct hv_device *dev, ...@@ -1040,16 +1039,15 @@ int rndis_filter_device_add(struct hv_device *dev,
return ret; return ret;
} }
/* Initialize the rndis device */ /* Initialize the rndis device */
net_device = hv_get_drvdata(dev); net_device = net_device_ctx->nvdev;
net_device->max_chn = 1; net_device->max_chn = 1;
net_device->num_chn = 1; net_device->num_chn = 1;
spin_lock_init(&net_device->sc_lock); spin_lock_init(&net_device->sc_lock);
net_device->extension = rndis_device; net_device->extension = rndis_device;
rndis_device->net_dev = net_device; rndis_device->ndev = net;
/* Send the rndis initialization message */ /* Send the rndis initialization message */
ret = rndis_filter_init_device(rndis_device); ret = rndis_filter_init_device(rndis_device);
...@@ -1063,8 +1061,8 @@ int rndis_filter_device_add(struct hv_device *dev, ...@@ -1063,8 +1061,8 @@ int rndis_filter_device_add(struct hv_device *dev,
ret = rndis_filter_query_device(rndis_device, ret = rndis_filter_query_device(rndis_device,
RNDIS_OID_GEN_MAXIMUM_FRAME_SIZE, RNDIS_OID_GEN_MAXIMUM_FRAME_SIZE,
&mtu, &size); &mtu, &size);
if (ret == 0 && size == sizeof(u32) && mtu < net_device->ndev->mtu) if (ret == 0 && size == sizeof(u32) && mtu < net->mtu)
net_device->ndev->mtu = mtu; net->mtu = mtu;
/* Get the mac address */ /* Get the mac address */
ret = rndis_filter_query_device_mac(rndis_device); ret = rndis_filter_query_device_mac(rndis_device);
...@@ -1198,7 +1196,9 @@ int rndis_filter_device_add(struct hv_device *dev, ...@@ -1198,7 +1196,9 @@ int rndis_filter_device_add(struct hv_device *dev,
void rndis_filter_device_remove(struct hv_device *dev) void rndis_filter_device_remove(struct hv_device *dev)
{ {
struct netvsc_device *net_dev = hv_get_drvdata(dev); struct net_device *ndev = hv_get_drvdata(dev);
struct net_device_context *net_device_ctx = netdev_priv(ndev);
struct netvsc_device *net_dev = net_device_ctx->nvdev;
struct rndis_device *rndis_dev = net_dev->extension; struct rndis_device *rndis_dev = net_dev->extension;
unsigned long t; unsigned long t;
...@@ -1224,7 +1224,9 @@ void rndis_filter_device_remove(struct hv_device *dev) ...@@ -1224,7 +1224,9 @@ void rndis_filter_device_remove(struct hv_device *dev)
int rndis_filter_open(struct hv_device *dev) int rndis_filter_open(struct hv_device *dev)
{ {
struct netvsc_device *net_device = hv_get_drvdata(dev); struct net_device *ndev = hv_get_drvdata(dev);
struct net_device_context *net_device_ctx = netdev_priv(ndev);
struct netvsc_device *net_device = net_device_ctx->nvdev;
if (!net_device) if (!net_device)
return -EINVAL; return -EINVAL;
...@@ -1237,7 +1239,9 @@ int rndis_filter_open(struct hv_device *dev) ...@@ -1237,7 +1239,9 @@ int rndis_filter_open(struct hv_device *dev)
int rndis_filter_close(struct hv_device *dev) int rndis_filter_close(struct hv_device *dev)
{ {
struct netvsc_device *nvdev = hv_get_drvdata(dev); struct net_device *ndev = hv_get_drvdata(dev);
struct net_device_context *net_device_ctx = netdev_priv(ndev);
struct netvsc_device *nvdev = net_device_ctx->nvdev;
if (!nvdev) if (!nvdev)
return -EINVAL; return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment