Lines Matching refs:net_device

34 int netvsc_switch_datapath(struct net_device *ndev, bool vf)  in netvsc_switch_datapath()
129 struct netvsc_device *net_device; in alloc_net_device() local
131 net_device = kzalloc(sizeof(struct netvsc_device), GFP_KERNEL); in alloc_net_device()
132 if (!net_device) in alloc_net_device()
135 init_waitqueue_head(&net_device->wait_drain); in alloc_net_device()
136 net_device->destroy = false; in alloc_net_device()
137 net_device->tx_disable = true; in alloc_net_device()
139 net_device->max_pkt = RNDIS_MAX_PKT_DEFAULT; in alloc_net_device()
140 net_device->pkt_align = RNDIS_PKT_ALIGN_DEFAULT; in alloc_net_device()
142 init_completion(&net_device->channel_init_wait); in alloc_net_device()
143 init_waitqueue_head(&net_device->subchan_open); in alloc_net_device()
144 INIT_WORK(&net_device->subchan_work, netvsc_subchan_work); in alloc_net_device()
146 return net_device; in alloc_net_device()
175 struct netvsc_device *net_device, in netvsc_revoke_recv_buf() argument
176 struct net_device *ndev) in netvsc_revoke_recv_buf()
187 if (net_device->recv_section_cnt) { in netvsc_revoke_recv_buf()
189 revoke_packet = &net_device->revoke_packet; in netvsc_revoke_recv_buf()
220 net_device->recv_section_cnt = 0; in netvsc_revoke_recv_buf()
225 struct netvsc_device *net_device, in netvsc_revoke_send_buf() argument
226 struct net_device *ndev) in netvsc_revoke_send_buf()
237 if (net_device->send_section_cnt) { in netvsc_revoke_send_buf()
239 revoke_packet = &net_device->revoke_packet; in netvsc_revoke_send_buf()
271 net_device->send_section_cnt = 0; in netvsc_revoke_send_buf()
276 struct netvsc_device *net_device, in netvsc_teardown_recv_gpadl() argument
277 struct net_device *ndev) in netvsc_teardown_recv_gpadl()
281 if (net_device->recv_buf_gpadl_handle.gpadl_handle) { in netvsc_teardown_recv_gpadl()
283 &net_device->recv_buf_gpadl_handle); in netvsc_teardown_recv_gpadl()
297 struct netvsc_device *net_device, in netvsc_teardown_send_gpadl() argument
298 struct net_device *ndev) in netvsc_teardown_send_gpadl()
302 if (net_device->send_buf_gpadl_handle.gpadl_handle) { in netvsc_teardown_send_gpadl()
304 &net_device->send_buf_gpadl_handle); in netvsc_teardown_send_gpadl()
317 int netvsc_alloc_recv_comp_ring(struct netvsc_device *net_device, u32 q_idx) in netvsc_alloc_recv_comp_ring() argument
319 struct netvsc_channel *nvchan = &net_device->chan_table[q_idx]; in netvsc_alloc_recv_comp_ring()
323 size = net_device->recv_completion_cnt * sizeof(struct recv_comp_data); in netvsc_alloc_recv_comp_ring()
332 struct netvsc_device *net_device, in netvsc_init_buf() argument
336 struct net_device *ndev = hv_get_drvdata(device); in netvsc_init_buf()
347 if (net_device->nvsp_version <= NVSP_PROTOCOL_VERSION_2) in netvsc_init_buf()
351 net_device->recv_buf = vzalloc(buf_size); in netvsc_init_buf()
352 if (!net_device->recv_buf) { in netvsc_init_buf()
360 net_device->recv_buf_size = buf_size; in netvsc_init_buf()
367 ret = vmbus_establish_gpadl(device->channel, net_device->recv_buf, in netvsc_init_buf()
369 &net_device->recv_buf_gpadl_handle); in netvsc_init_buf()
377 init_packet = &net_device->channel_init_pkt; in netvsc_init_buf()
381 gpadl_handle = net_device->recv_buf_gpadl_handle.gpadl_handle; in netvsc_init_buf()
399 wait_for_completion(&net_device->channel_init_wait); in netvsc_init_buf()
422 net_device->recv_section_size = resp->sections[0].sub_alloc_size; in netvsc_init_buf()
423 net_device->recv_section_cnt = resp->sections[0].num_sub_allocs; in netvsc_init_buf()
426 if (net_device->recv_section_size < NETVSC_MTU_MIN || (u64)net_device->recv_section_size * in netvsc_init_buf()
427 (u64)net_device->recv_section_cnt > (u64)buf_size) { in netvsc_init_buf()
429 net_device->recv_section_size); in netvsc_init_buf()
435 struct netvsc_channel *nvchan = &net_device->chan_table[i]; in netvsc_init_buf()
437 nvchan->recv_buf = kzalloc(net_device->recv_section_size, GFP_KERNEL); in netvsc_init_buf()
448 net_device->recv_completion_cnt = net_device->recv_section_cnt + 1; in netvsc_init_buf()
449 ret = netvsc_alloc_recv_comp_ring(net_device, 0); in netvsc_init_buf()
457 net_device->send_buf = vzalloc(buf_size); in netvsc_init_buf()
458 if (!net_device->send_buf) { in netvsc_init_buf()
464 net_device->send_buf_size = buf_size; in netvsc_init_buf()
470 ret = vmbus_establish_gpadl(device->channel, net_device->send_buf, in netvsc_init_buf()
472 &net_device->send_buf_gpadl_handle); in netvsc_init_buf()
480 init_packet = &net_device->channel_init_pkt; in netvsc_init_buf()
484 net_device->send_buf_gpadl_handle.gpadl_handle; in netvsc_init_buf()
501 wait_for_completion(&net_device->channel_init_wait); in netvsc_init_buf()
515 net_device->send_section_size = init_packet->msg. in netvsc_init_buf()
517 if (net_device->send_section_size < NETVSC_MTU_MIN) { in netvsc_init_buf()
519 net_device->send_section_size); in netvsc_init_buf()
525 net_device->send_section_cnt = buf_size / net_device->send_section_size; in netvsc_init_buf()
528 net_device->send_section_size, net_device->send_section_cnt); in netvsc_init_buf()
531 map_words = DIV_ROUND_UP(net_device->send_section_cnt, BITS_PER_LONG); in netvsc_init_buf()
533 net_device->send_section_map = kcalloc(map_words, sizeof(ulong), GFP_KERNEL); in netvsc_init_buf()
534 if (net_device->send_section_map == NULL) { in netvsc_init_buf()
542 netvsc_revoke_recv_buf(device, net_device, ndev); in netvsc_init_buf()
543 netvsc_revoke_send_buf(device, net_device, ndev); in netvsc_init_buf()
544 netvsc_teardown_recv_gpadl(device, net_device, ndev); in netvsc_init_buf()
545 netvsc_teardown_send_gpadl(device, net_device, ndev); in netvsc_init_buf()
553 struct netvsc_device *net_device, in negotiate_nvsp_ver() argument
557 struct net_device *ndev = hv_get_drvdata(device); in negotiate_nvsp_ver()
576 wait_for_completion(&net_device->channel_init_wait); in negotiate_nvsp_ver()
615 struct netvsc_device *net_device, in netvsc_connect_vsp() argument
618 struct net_device *ndev = hv_get_drvdata(device); in netvsc_connect_vsp()
627 init_packet = &net_device->channel_init_pkt; in netvsc_connect_vsp()
631 if (negotiate_nvsp_ver(device, net_device, init_packet, in netvsc_connect_vsp()
633 net_device->nvsp_version = ver_list[i]; in netvsc_connect_vsp()
642 if (hv_is_isolation_supported() && net_device->nvsp_version < NVSP_PROTOCOL_VERSION_61) { in netvsc_connect_vsp()
644 net_device->nvsp_version, NVSP_PROTOCOL_VERSION_61); in netvsc_connect_vsp()
649 pr_debug("Negotiated NVSP version:%x\n", net_device->nvsp_version); in netvsc_connect_vsp()
654 if (net_device->nvsp_version <= NVSP_PROTOCOL_VERSION_4) in netvsc_connect_vsp()
678 ret = netvsc_init_buf(device, net_device, device_info); in netvsc_connect_vsp()
689 struct net_device *ndev = hv_get_drvdata(device); in netvsc_device_remove()
691 struct netvsc_device *net_device in netvsc_device_remove() local
699 netvsc_revoke_recv_buf(device, net_device, ndev); in netvsc_device_remove()
701 netvsc_teardown_recv_gpadl(device, net_device, ndev); in netvsc_device_remove()
703 netvsc_revoke_send_buf(device, net_device, ndev); in netvsc_device_remove()
705 netvsc_teardown_send_gpadl(device, net_device, ndev); in netvsc_device_remove()
710 for (i = 0; i < net_device->num_chn; i++) { in netvsc_device_remove()
712 napi_disable(&net_device->chan_table[i].napi); in netvsc_device_remove()
713 netif_napi_del(&net_device->chan_table[i].napi); in netvsc_device_remove()
730 netvsc_teardown_recv_gpadl(device, net_device, ndev); in netvsc_device_remove()
731 netvsc_teardown_send_gpadl(device, net_device, ndev); in netvsc_device_remove()
735 free_netvsc_device_rcu(net_device); in netvsc_device_remove()
741 static inline void netvsc_free_send_slot(struct netvsc_device *net_device, in netvsc_free_send_slot() argument
744 sync_change_bit(index, net_device->send_section_map); in netvsc_free_send_slot()
747 static void netvsc_send_tx_complete(struct net_device *ndev, in netvsc_send_tx_complete()
748 struct netvsc_device *net_device, in netvsc_send_tx_complete() argument
775 netvsc_free_send_slot(net_device, send_index); in netvsc_send_tx_complete()
778 tx_stats = &net_device->chan_table[q_idx].tx_stats; in netvsc_send_tx_complete()
789 atomic_dec_return(&net_device->chan_table[q_idx].queue_sends); in netvsc_send_tx_complete()
791 if (unlikely(net_device->destroy)) { in netvsc_send_tx_complete()
793 wake_up(&net_device->wait_drain); in netvsc_send_tx_complete()
797 if (netif_tx_queue_stopped(txq) && !net_device->tx_disable && in netvsc_send_tx_complete()
806 static void netvsc_send_completion(struct net_device *ndev, in netvsc_send_completion()
807 struct netvsc_device *net_device, in netvsc_send_completion() argument
829 complete(&net_device->channel_init_wait); in netvsc_send_completion()
881 memcpy(&net_device->channel_init_pkt, nvsp_packet, in netvsc_send_completion()
883 complete(&net_device->channel_init_wait); in netvsc_send_completion()
887 netvsc_send_tx_complete(ndev, net_device, incoming_channel, in netvsc_send_completion()
898 static u32 netvsc_get_next_send_section(struct netvsc_device *net_device) in netvsc_get_next_send_section() argument
900 unsigned long *map_addr = net_device->send_section_map; in netvsc_get_next_send_section()
903 for_each_clear_bit(i, map_addr, net_device->send_section_cnt) { in netvsc_get_next_send_section()
911 static void netvsc_copy_to_send_buf(struct netvsc_device *net_device, in netvsc_copy_to_send_buf() argument
919 char *start = net_device->send_buf; in netvsc_copy_to_send_buf()
920 char *dest = start + (section_index * net_device->send_section_size) in netvsc_copy_to_send_buf()
929 remain = packet->total_data_buflen & (net_device->pkt_align - 1); in netvsc_copy_to_send_buf()
931 padding = net_device->pkt_align - remain; in netvsc_copy_to_send_buf()
952 struct netvsc_device *net_device, in netvsc_send_pkt() argument
960 &net_device->chan_table[packet->q_idx]; in netvsc_send_pkt()
962 struct net_device *ndev = hv_get_drvdata(device); in netvsc_send_pkt()
1023 !net_device->tx_disable) { in netvsc_send_pkt()
1066 int netvsc_send(struct net_device *ndev, in netvsc_send()
1074 struct netvsc_device *net_device in netvsc_send() local
1087 if (unlikely(!net_device || net_device->destroy)) in netvsc_send()
1090 nvchan = &net_device->chan_table[packet->q_idx]; in netvsc_send()
1099 return netvsc_send_pkt(device, packet, net_device, pb, skb); in netvsc_send()
1106 try_batch = msd_len > 0 && msdp->count < net_device->max_pkt; in netvsc_send()
1107 if (try_batch && msd_len + pktlen + net_device->pkt_align < in netvsc_send()
1108 net_device->send_section_size) { in netvsc_send()
1112 net_device->send_section_size) { in netvsc_send()
1116 } else if (pktlen + net_device->pkt_align < in netvsc_send()
1117 net_device->send_section_size) { in netvsc_send()
1118 section_index = netvsc_get_next_send_section(net_device); in netvsc_send()
1135 netvsc_copy_to_send_buf(net_device, in netvsc_send()
1173 int m_ret = netvsc_send_pkt(device, msd_send, net_device, in netvsc_send()
1177 netvsc_free_send_slot(net_device, in netvsc_send()
1184 ret = netvsc_send_pkt(device, cur_send, net_device, pb, skb); in netvsc_send()
1187 netvsc_free_send_slot(net_device, section_index); in netvsc_send()
1193 static int send_recv_completions(struct net_device *ndev, in send_recv_completions()
1248 static void enq_receive_complete(struct net_device *ndev, in enq_receive_complete()
1278 static int netvsc_receive(struct net_device *ndev, in netvsc_receive()
1279 struct netvsc_device *net_device, in netvsc_receive() argument
1290 char *recv_buf = net_device->recv_buf; in netvsc_receive()
1344 if (unlikely(offset > net_device->recv_buf_size || in netvsc_receive()
1345 buflen > net_device->recv_buf_size - offset)) { in netvsc_receive()
1358 if (unlikely(buflen > net_device->recv_section_size)) { in netvsc_receive()
1363 buflen, net_device->recv_section_size); in netvsc_receive()
1375 ret = rndis_filter_receive(ndev, net_device, in netvsc_receive()
1385 enq_receive_complete(ndev, net_device, q_idx, in netvsc_receive()
1391 static void netvsc_send_table(struct net_device *ndev, in netvsc_send_table()
1437 static void netvsc_send_vf(struct net_device *ndev, in netvsc_send_vf()
1457 static void netvsc_receive_inband(struct net_device *ndev, in netvsc_receive_inband()
1486 struct netvsc_device *net_device, in netvsc_process_raw_pkt() argument
1487 struct net_device *ndev, in netvsc_process_raw_pkt()
1498 netvsc_send_completion(ndev, net_device, channel, desc, budget); in netvsc_process_raw_pkt()
1502 return netvsc_receive(ndev, net_device, nvchan, desc); in netvsc_process_raw_pkt()
1506 netvsc_receive_inband(ndev, net_device, desc); in netvsc_process_raw_pkt()
1533 struct netvsc_device *net_device = nvchan->net_device; in netvsc_poll() local
1536 struct net_device *ndev = hv_get_drvdata(device); in netvsc_poll()
1545 work_done += netvsc_process_raw_pkt(device, nvchan, net_device, in netvsc_poll()
1551 ret = send_recv_completions(ndev, net_device, nvchan); in netvsc_poll()
1599 struct netvsc_device *net_device; in netvsc_device_add() local
1600 struct net_device *ndev = hv_get_drvdata(device); in netvsc_device_add()
1603 net_device = alloc_net_device(); in netvsc_device_add()
1604 if (!net_device) in netvsc_device_add()
1623 struct netvsc_channel *nvchan = &net_device->chan_table[i]; in netvsc_device_add()
1626 nvchan->net_device = net_device; in netvsc_device_add()
1647 netif_napi_add(ndev, &net_device->chan_table[0].napi, in netvsc_device_add()
1658 netvsc_channel_cb, net_device->chan_table); in netvsc_device_add()
1668 napi_enable(&net_device->chan_table[0].napi); in netvsc_device_add()
1671 ret = netvsc_connect_vsp(device, net_device, device_info); in netvsc_device_add()
1681 rcu_assign_pointer(net_device_ctx->nvdev, net_device); in netvsc_device_add()
1683 return net_device; in netvsc_device_add()
1687 napi_disable(&net_device->chan_table[0].napi); in netvsc_device_add()
1693 netif_napi_del(&net_device->chan_table[0].napi); in netvsc_device_add()
1696 free_netvsc_device(&net_device->rcu); in netvsc_device_add()