Lines Matching defs:net_device

35 int netvsc_switch_datapath(struct net_device *ndev, bool vf)
130 struct netvsc_device *net_device;
132 net_device = kzalloc(sizeof(struct netvsc_device), GFP_KERNEL);
133 if (!net_device)
136 init_waitqueue_head(&net_device->wait_drain);
137 net_device->destroy = false;
138 net_device->tx_disable = true;
140 net_device->max_pkt = RNDIS_MAX_PKT_DEFAULT;
141 net_device->pkt_align = RNDIS_PKT_ALIGN_DEFAULT;
143 init_completion(&net_device->channel_init_wait);
144 init_waitqueue_head(&net_device->subchan_open);
145 INIT_WORK(&net_device->subchan_work, netvsc_subchan_work);
147 return net_device;
176 struct netvsc_device *net_device,
177 struct net_device *ndev)
188 if (net_device->recv_section_cnt) {
190 revoke_packet = &net_device->revoke_packet;
221 net_device->recv_section_cnt = 0;
226 struct netvsc_device *net_device,
227 struct net_device *ndev)
238 if (net_device->send_section_cnt) {
240 revoke_packet = &net_device->revoke_packet;
272 net_device->send_section_cnt = 0;
277 struct netvsc_device *net_device,
278 struct net_device *ndev)
282 if (net_device->recv_buf_gpadl_handle.gpadl_handle) {
284 &net_device->recv_buf_gpadl_handle);
298 struct netvsc_device *net_device,
299 struct net_device *ndev)
303 if (net_device->send_buf_gpadl_handle.gpadl_handle) {
305 &net_device->send_buf_gpadl_handle);
318 int netvsc_alloc_recv_comp_ring(struct netvsc_device *net_device, u32 q_idx)
320 struct netvsc_channel *nvchan = &net_device->chan_table[q_idx];
324 size = net_device->recv_completion_cnt * sizeof(struct recv_comp_data);
333 struct netvsc_device *net_device,
337 struct net_device *ndev = hv_get_drvdata(device);
347 if (net_device->nvsp_version <= NVSP_PROTOCOL_VERSION_2)
351 net_device->recv_buf = vzalloc(buf_size);
352 if (!net_device->recv_buf) {
360 net_device->recv_buf_size = buf_size;
367 ret = vmbus_establish_gpadl(device->channel, net_device->recv_buf,
369 &net_device->recv_buf_gpadl_handle);
377 init_packet = &net_device->channel_init_pkt;
381 gpadl_handle = net_device->recv_buf_gpadl_handle.gpadl_handle;
399 wait_for_completion(&net_device->channel_init_wait);
422 net_device->recv_section_size = resp->sections[0].sub_alloc_size;
423 net_device->recv_section_cnt = resp->sections[0].num_sub_allocs;
426 if (net_device->recv_section_size < NETVSC_MTU_MIN || (u64)net_device->recv_section_size *
427 (u64)net_device->recv_section_cnt > (u64)buf_size) {
429 net_device->recv_section_size);
435 struct netvsc_channel *nvchan = &net_device->chan_table[i];
437 nvchan->recv_buf = kzalloc(net_device->recv_section_size, GFP_KERNEL);
448 net_device->recv_completion_cnt = net_device->recv_section_cnt + 1;
449 ret = netvsc_alloc_recv_comp_ring(net_device, 0);
457 net_device->send_buf = vzalloc(buf_size);
458 if (!net_device->send_buf) {
464 net_device->send_buf_size = buf_size;
470 ret = vmbus_establish_gpadl(device->channel, net_device->send_buf,
472 &net_device->send_buf_gpadl_handle);
480 init_packet = &net_device->channel_init_pkt;
484 net_device->send_buf_gpadl_handle.gpadl_handle;
501 wait_for_completion(&net_device->channel_init_wait);
515 net_device->send_section_size = init_packet->msg.
517 if (net_device->send_section_size < NETVSC_MTU_MIN) {
519 net_device->send_section_size);
525 net_device->send_section_cnt = buf_size / net_device->send_section_size;
528 net_device->send_section_size, net_device->send_section_cnt);
531 net_device->send_section_map = bitmap_zalloc(net_device->send_section_cnt,
533 if (!net_device->send_section_map) {
541 netvsc_revoke_recv_buf(device, net_device, ndev);
542 netvsc_revoke_send_buf(device, net_device, ndev);
543 netvsc_teardown_recv_gpadl(device, net_device, ndev);
544 netvsc_teardown_send_gpadl(device, net_device, ndev);
552 struct netvsc_device *net_device,
556 struct net_device *ndev = hv_get_drvdata(device);
575 wait_for_completion(&net_device->channel_init_wait);
614 struct netvsc_device *net_device,
617 struct net_device *ndev = hv_get_drvdata(device);
626 init_packet = &net_device->channel_init_pkt;
630 if (negotiate_nvsp_ver(device, net_device, init_packet,
632 net_device->nvsp_version = ver_list[i];
641 if (hv_is_isolation_supported() && net_device->nvsp_version < NVSP_PROTOCOL_VERSION_61) {
643 net_device->nvsp_version, NVSP_PROTOCOL_VERSION_61);
648 pr_debug("Negotiated NVSP version:%x\n", net_device->nvsp_version);
653 if (net_device->nvsp_version <= NVSP_PROTOCOL_VERSION_4)
677 ret = netvsc_init_buf(device, net_device, device_info);
688 struct net_device *ndev = hv_get_drvdata(device);
690 struct netvsc_device *net_device
698 netvsc_revoke_recv_buf(device, net_device, ndev);
700 netvsc_teardown_recv_gpadl(device, net_device, ndev);
702 netvsc_revoke_send_buf(device, net_device, ndev);
704 netvsc_teardown_send_gpadl(device, net_device, ndev);
709 for (i = 0; i < net_device->num_chn; i++) {
713 napi_disable(&net_device->chan_table[i].napi);
715 netif_napi_del(&net_device->chan_table[i].napi);
719 * At this point, no one should be accessing net_device
732 netvsc_teardown_recv_gpadl(device, net_device, ndev);
733 netvsc_teardown_send_gpadl(device, net_device, ndev);
737 free_netvsc_device_rcu(net_device);
743 static inline void netvsc_free_send_slot(struct netvsc_device *net_device,
746 sync_change_bit(index, net_device->send_section_map);
749 static void netvsc_send_tx_complete(struct net_device *ndev,
750 struct netvsc_device *net_device,
777 netvsc_free_send_slot(net_device, send_index);
780 tx_stats = &net_device->chan_table[q_idx].tx_stats;
792 atomic_dec_return(&net_device->chan_table[q_idx].queue_sends);
794 if (unlikely(net_device->destroy)) {
796 wake_up(&net_device->wait_drain);
800 if (netif_tx_queue_stopped(txq) && !net_device->tx_disable &&
809 static void netvsc_send_completion(struct net_device *ndev,
810 struct netvsc_device *net_device,
833 complete(&net_device->channel_init_wait);
885 memcpy(&net_device->channel_init_pkt, nvsp_packet,
887 complete(&net_device->channel_init_wait);
908 netvsc_send_tx_complete(ndev, net_device, incoming_channel,
919 static u32 netvsc_get_next_send_section(struct netvsc_device *net_device)
921 unsigned long *map_addr = net_device->send_section_map;
924 for_each_clear_bit(i, map_addr, net_device->send_section_cnt) {
932 static void netvsc_copy_to_send_buf(struct netvsc_device *net_device,
940 char *start = net_device->send_buf;
941 char *dest = start + (section_index * net_device->send_section_size)
950 remain = packet->total_data_buflen & (net_device->pkt_align - 1);
952 padding = net_device->pkt_align - remain;
1050 struct netvsc_device *net_device,
1058 &net_device->chan_table[packet->q_idx];
1060 struct net_device *ndev = hv_get_drvdata(device);
1132 !net_device->tx_disable) {
1175 int netvsc_send(struct net_device *ndev,
1183 struct netvsc_device *net_device
1196 if (unlikely(!net_device || net_device->destroy))
1199 nvchan = &net_device->chan_table[packet->q_idx];
1208 return netvsc_send_pkt(device, packet, net_device, pb, skb);
1215 try_batch = msd_len > 0 && msdp->count < net_device->max_pkt;
1216 if (try_batch && msd_len + pktlen + net_device->pkt_align <
1217 net_device->send_section_size) {
1221 net_device->send_section_size) {
1225 } else if (pktlen + net_device->pkt_align <
1226 net_device->send_section_size) {
1227 section_index = netvsc_get_next_send_section(net_device);
1244 netvsc_copy_to_send_buf(net_device,
1282 int m_ret = netvsc_send_pkt(device, msd_send, net_device,
1286 netvsc_free_send_slot(net_device,
1293 ret = netvsc_send_pkt(device, cur_send, net_device, pb, skb);
1296 netvsc_free_send_slot(net_device, section_index);
1302 static int send_recv_completions(struct net_device *ndev,
1357 static void enq_receive_complete(struct net_device *ndev,
1387 static int netvsc_receive(struct net_device *ndev,
1388 struct netvsc_device *net_device,
1399 char *recv_buf = net_device->recv_buf;
1453 if (unlikely(offset > net_device->recv_buf_size ||
1454 buflen > net_device->recv_buf_size - offset)) {
1467 if (unlikely(buflen > net_device->recv_section_size)) {
1472 buflen, net_device->recv_section_size);
1484 ret = rndis_filter_receive(ndev, net_device,
1494 enq_receive_complete(ndev, net_device, q_idx,
1500 static void netvsc_send_table(struct net_device *ndev,
1546 static void netvsc_send_vf(struct net_device *ndev,
1570 static void netvsc_receive_inband(struct net_device *ndev,
1599 struct netvsc_device *net_device,
1600 struct net_device *ndev,
1611 netvsc_send_completion(ndev, net_device, channel, desc, budget);
1615 return netvsc_receive(ndev, net_device, nvchan, desc);
1618 netvsc_receive_inband(ndev, net_device, desc);
1645 struct netvsc_device *net_device = nvchan->net_device;
1648 struct net_device *ndev = hv_get_drvdata(device);
1659 work_done += netvsc_process_raw_pkt(device, nvchan, net_device,
1668 ret = send_recv_completions(ndev, net_device, nvchan);
1716 struct netvsc_device *net_device;
1717 struct net_device *ndev = hv_get_drvdata(device);
1720 net_device = alloc_net_device();
1721 if (!net_device)
1740 struct netvsc_channel *nvchan = &net_device->chan_table[i];
1743 nvchan->net_device = net_device;
1764 netif_napi_add(ndev, &net_device->chan_table[0].napi, netvsc_poll);
1774 netvsc_channel_cb, net_device->chan_table);
1784 napi_enable(&net_device->chan_table[0].napi);
1787 ret = netvsc_connect_vsp(device, net_device, device_info);
1797 rcu_assign_pointer(net_device_ctx->nvdev, net_device);
1799 return net_device;
1803 napi_disable(&net_device->chan_table[0].napi);
1809 netif_napi_del(&net_device->chan_table[0].napi);
1812 free_netvsc_device(&net_device->rcu);