Lines Matching refs:net_device
38 struct netvsc_device *net_device; in alloc_net_device() local
39 struct net_device *ndev = hv_get_drvdata(device); in alloc_net_device()
41 net_device = kzalloc(sizeof(struct netvsc_device), GFP_KERNEL); in alloc_net_device()
42 if (!net_device) in alloc_net_device()
45 init_waitqueue_head(&net_device->wait_drain); in alloc_net_device()
46 net_device->start_remove = false; in alloc_net_device()
47 net_device->destroy = false; in alloc_net_device()
48 net_device->dev = device; in alloc_net_device()
49 net_device->ndev = ndev; in alloc_net_device()
51 hv_set_drvdata(device, net_device); in alloc_net_device()
52 return net_device; in alloc_net_device()
57 struct netvsc_device *net_device; in get_outbound_net_device() local
59 net_device = hv_get_drvdata(device); in get_outbound_net_device()
60 if (net_device && net_device->destroy) in get_outbound_net_device()
61 net_device = NULL; in get_outbound_net_device()
63 return net_device; in get_outbound_net_device()
68 struct netvsc_device *net_device; in get_inbound_net_device() local
70 net_device = hv_get_drvdata(device); in get_inbound_net_device()
72 if (!net_device) in get_inbound_net_device()
75 if (net_device->destroy && in get_inbound_net_device()
76 atomic_read(&net_device->num_outstanding_sends) == 0) in get_inbound_net_device()
77 net_device = NULL; in get_inbound_net_device()
80 return net_device; in get_inbound_net_device()
84 static int netvsc_destroy_recv_buf(struct netvsc_device *net_device) in netvsc_destroy_recv_buf() argument
88 struct net_device *ndev = net_device->ndev; in netvsc_destroy_recv_buf()
96 if (net_device->recv_section_cnt) { in netvsc_destroy_recv_buf()
98 revoke_packet = &net_device->revoke_packet; in netvsc_destroy_recv_buf()
106 ret = vmbus_sendpacket(net_device->dev->channel, in netvsc_destroy_recv_buf()
123 if (net_device->recv_buf_gpadl_handle) { in netvsc_destroy_recv_buf()
124 ret = vmbus_teardown_gpadl(net_device->dev->channel, in netvsc_destroy_recv_buf()
125 net_device->recv_buf_gpadl_handle); in netvsc_destroy_recv_buf()
135 net_device->recv_buf_gpadl_handle = 0; in netvsc_destroy_recv_buf()
138 if (net_device->recv_buf) { in netvsc_destroy_recv_buf()
140 free_pages((unsigned long)net_device->recv_buf, in netvsc_destroy_recv_buf()
141 get_order(net_device->recv_buf_size)); in netvsc_destroy_recv_buf()
142 net_device->recv_buf = NULL; in netvsc_destroy_recv_buf()
145 if (net_device->recv_section) { in netvsc_destroy_recv_buf()
146 net_device->recv_section_cnt = 0; in netvsc_destroy_recv_buf()
147 kfree(net_device->recv_section); in netvsc_destroy_recv_buf()
148 net_device->recv_section = NULL; in netvsc_destroy_recv_buf()
158 struct netvsc_device *net_device; in netvsc_init_recv_buf() local
160 struct net_device *ndev; in netvsc_init_recv_buf()
162 net_device = get_outbound_net_device(device); in netvsc_init_recv_buf()
163 if (!net_device) in netvsc_init_recv_buf()
165 ndev = net_device->ndev; in netvsc_init_recv_buf()
167 net_device->recv_buf = in netvsc_init_recv_buf()
169 get_order(net_device->recv_buf_size)); in netvsc_init_recv_buf()
170 if (!net_device->recv_buf) { in netvsc_init_recv_buf()
172 "buffer of size %d\n", net_device->recv_buf_size); in netvsc_init_recv_buf()
182 ret = vmbus_establish_gpadl(device->channel, net_device->recv_buf, in netvsc_init_recv_buf()
183 net_device->recv_buf_size, in netvsc_init_recv_buf()
184 &net_device->recv_buf_gpadl_handle); in netvsc_init_recv_buf()
193 init_packet = &net_device->channel_init_pkt; in netvsc_init_recv_buf()
199 gpadl_handle = net_device->recv_buf_gpadl_handle; in netvsc_init_recv_buf()
215 t = wait_for_completion_timeout(&net_device->channel_init_wait, 5*HZ); in netvsc_init_recv_buf()
232 net_device->recv_section_cnt = init_packet->msg. in netvsc_init_recv_buf()
235 net_device->recv_section = kmemdup( in netvsc_init_recv_buf()
237 net_device->recv_section_cnt * in netvsc_init_recv_buf()
240 if (net_device->recv_section == NULL) { in netvsc_init_recv_buf()
249 if (net_device->recv_section_cnt != 1 || in netvsc_init_recv_buf()
250 net_device->recv_section->offset != 0) { in netvsc_init_recv_buf()
258 netvsc_destroy_recv_buf(net_device); in netvsc_init_recv_buf()
267 struct netvsc_device *net_device, in negotiate_nvsp_ver() argument
288 t = wait_for_completion_timeout(&net_device->channel_init_wait, 5*HZ); in negotiate_nvsp_ver()
303 init_packet->msg.v2_msg.send_ndis_config.mtu = net_device->ndev->mtu; in negotiate_nvsp_ver()
317 struct netvsc_device *net_device; in netvsc_connect_vsp() local
320 struct net_device *ndev; in netvsc_connect_vsp()
322 net_device = get_outbound_net_device(device); in netvsc_connect_vsp()
323 if (!net_device) in netvsc_connect_vsp()
325 ndev = net_device->ndev; in netvsc_connect_vsp()
327 init_packet = &net_device->channel_init_pkt; in netvsc_connect_vsp()
330 if (negotiate_nvsp_ver(device, net_device, init_packet, in netvsc_connect_vsp()
332 net_device->nvsp_version = NVSP_PROTOCOL_VERSION_2; in netvsc_connect_vsp()
333 } else if (negotiate_nvsp_ver(device, net_device, init_packet, in netvsc_connect_vsp()
335 net_device->nvsp_version = NVSP_PROTOCOL_VERSION_1; in netvsc_connect_vsp()
341 pr_debug("Negotiated NVSP version:%x\n", net_device->nvsp_version); in netvsc_connect_vsp()
371 static void netvsc_disconnect_vsp(struct netvsc_device *net_device) in netvsc_disconnect_vsp() argument
373 netvsc_destroy_recv_buf(net_device); in netvsc_disconnect_vsp()
381 struct netvsc_device *net_device; in netvsc_device_remove() local
385 net_device = hv_get_drvdata(device); in netvsc_device_remove()
387 netvsc_disconnect_vsp(net_device); in netvsc_device_remove()
412 &net_device->recv_pkt_list, list_ent) { in netvsc_device_remove()
417 kfree(net_device); in netvsc_device_remove()
442 struct netvsc_device *net_device; in netvsc_send_completion() local
445 struct net_device *ndev; in netvsc_send_completion()
447 net_device = get_inbound_net_device(device); in netvsc_send_completion()
448 if (!net_device) in netvsc_send_completion()
450 ndev = net_device->ndev; in netvsc_send_completion()
461 memcpy(&net_device->channel_init_pkt, nvsp_packet, in netvsc_send_completion()
463 complete(&net_device->channel_init_wait); in netvsc_send_completion()
479 atomic_dec_return(&net_device->num_outstanding_sends); in netvsc_send_completion()
481 if (net_device->destroy && num_outstanding_sends == 0) in netvsc_send_completion()
482 wake_up(&net_device->wait_drain); in netvsc_send_completion()
484 if (netif_queue_stopped(ndev) && !net_device->start_remove && in netvsc_send_completion()
499 struct netvsc_device *net_device; in netvsc_send() local
502 struct net_device *ndev; in netvsc_send()
505 net_device = get_outbound_net_device(device); in netvsc_send()
506 if (!net_device) in netvsc_send()
508 ndev = net_device->ndev; in netvsc_send()
545 atomic_inc(&net_device->num_outstanding_sends); in netvsc_send()
549 if (atomic_read(&net_device-> in netvsc_send()
555 if (atomic_read(&net_device->num_outstanding_sends) < 1) { in netvsc_send()
573 struct net_device *ndev; in netvsc_send_recv_completion()
574 struct netvsc_device *net_device = hv_get_drvdata(device); in netvsc_send_recv_completion() local
576 ndev = net_device->ndev; in netvsc_send_recv_completion()
616 struct netvsc_device *net_device; in netvsc_receive_completion() local
620 struct net_device *ndev; in netvsc_receive_completion()
628 net_device = get_inbound_net_device(device); in netvsc_receive_completion()
629 if (!net_device) in netvsc_receive_completion()
631 ndev = net_device->ndev; in netvsc_receive_completion()
634 spin_lock_irqsave(&net_device->recv_pkt_list_lock, flags); in netvsc_receive_completion()
650 &net_device->recv_pkt_list); in netvsc_receive_completion()
655 list_add_tail(&packet->list_ent, &net_device->recv_pkt_list); in netvsc_receive_completion()
656 spin_unlock_irqrestore(&net_device->recv_pkt_list_lock, flags); in netvsc_receive_completion()
667 struct netvsc_device *net_device; in netvsc_receive() local
676 struct net_device *ndev; in netvsc_receive()
680 net_device = get_inbound_net_device(device); in netvsc_receive()
681 if (!net_device) in netvsc_receive()
683 ndev = net_device->ndev; in netvsc_receive()
721 spin_lock_irqsave(&net_device->recv_pkt_list_lock, flags); in netvsc_receive()
722 while (!list_empty(&net_device->recv_pkt_list)) { in netvsc_receive()
723 list_move_tail(net_device->recv_pkt_list.next, &listHead); in netvsc_receive()
727 spin_unlock_irqrestore(&net_device->recv_pkt_list_lock, flags); in netvsc_receive()
740 spin_lock_irqsave(&net_device->recv_pkt_list_lock, flags); in netvsc_receive()
743 &net_device->recv_pkt_list); in netvsc_receive()
745 spin_unlock_irqrestore(&net_device->recv_pkt_list_lock, in netvsc_receive()
786 netvsc_packet->data = (void *)((unsigned long)net_device-> in netvsc_receive()
804 struct netvsc_device *net_device; in netvsc_channel_cb() local
811 struct net_device *ndev; in netvsc_channel_cb()
819 net_device = get_inbound_net_device(device); in netvsc_channel_cb()
820 if (!net_device) in netvsc_channel_cb()
822 ndev = net_device->ndev; in netvsc_channel_cb()
894 struct netvsc_device *net_device; in netvsc_device_add() local
896 struct net_device *ndev; in netvsc_device_add()
898 net_device = alloc_net_device(device); in netvsc_device_add()
899 if (!net_device) { in netvsc_device_add()
911 ndev = net_device->ndev; in netvsc_device_add()
914 net_device->recv_buf_size = NETVSC_RECEIVE_BUFFER_SIZE; in netvsc_device_add()
915 spin_lock_init(&net_device->recv_pkt_list_lock); in netvsc_device_add()
917 INIT_LIST_HEAD(&net_device->recv_pkt_list); in netvsc_device_add()
925 &net_device->recv_pkt_list); in netvsc_device_add()
927 init_completion(&net_device->channel_init_wait); in netvsc_device_add()
958 if (net_device) { in netvsc_device_add()
960 &net_device->recv_pkt_list, in netvsc_device_add()
966 kfree(net_device); in netvsc_device_add()