Lines Matching full:nc

151 void qemu_set_info_str(NetClientState *nc, const char *fmt, ...)  in qemu_set_info_str()  argument
156 vsnprintf(nc->info_str, sizeof(nc->info_str), fmt, ap); in qemu_set_info_str()
160 void qemu_format_nic_info_str(NetClientState *nc, uint8_t macaddr[6]) in qemu_format_nic_info_str() argument
162 qemu_set_info_str(nc, "model=%s,macaddr=%02x:%02x:%02x:%02x:%02x:%02x", in qemu_format_nic_info_str()
163 nc->model, macaddr[0], macaddr[1], macaddr[2], in qemu_format_nic_info_str()
238 NetClientState *nc; in assign_name() local
241 QTAILQ_FOREACH(nc, &net_clients, next) { in assign_name()
242 if (nc == nc1) { in assign_name()
245 if (strcmp(nc->model, model) == 0) { in assign_name()
253 static void qemu_net_client_destructor(NetClientState *nc) in qemu_net_client_destructor() argument
255 g_free(nc); in qemu_net_client_destructor()
263 static void qemu_net_client_setup(NetClientState *nc, in qemu_net_client_setup() argument
271 nc->info = info; in qemu_net_client_setup()
272 nc->model = g_strdup(model); in qemu_net_client_setup()
274 nc->name = g_strdup(name); in qemu_net_client_setup()
276 nc->name = assign_name(nc, model); in qemu_net_client_setup()
281 nc->peer = peer; in qemu_net_client_setup()
282 peer->peer = nc; in qemu_net_client_setup()
284 QTAILQ_INSERT_TAIL(&net_clients, nc, next); in qemu_net_client_setup()
286 nc->incoming_queue = qemu_new_net_queue(qemu_deliver_packet_iov, nc); in qemu_net_client_setup()
287 nc->destructor = destructor; in qemu_net_client_setup()
288 nc->is_datapath = is_datapath; in qemu_net_client_setup()
289 QTAILQ_INIT(&nc->filters); in qemu_net_client_setup()
297 NetClientState *nc; in qemu_new_net_client() local
301 nc = g_malloc0(info->size); in qemu_new_net_client()
302 qemu_net_client_setup(nc, info, peer, model, name, in qemu_new_net_client()
305 return nc; in qemu_new_net_client()
313 NetClientState *nc; in qemu_new_net_control_client() local
317 nc = g_malloc0(info->size); in qemu_new_net_control_client()
318 qemu_net_client_setup(nc, info, peer, model, name, in qemu_new_net_control_client()
321 return nc; in qemu_new_net_control_client()
363 NICState *qemu_get_nic(NetClientState *nc) in qemu_get_nic() argument
365 NetClientState *nc0 = nc - nc->queue_index; in qemu_get_nic()
367 return (NICState *)((void *)nc0 - nc->info->size); in qemu_get_nic()
370 void *qemu_get_nic_opaque(NetClientState *nc) in qemu_get_nic_opaque() argument
372 NICState *nic = qemu_get_nic(nc); in qemu_get_nic_opaque()
377 NetClientState *qemu_get_peer(NetClientState *nc, int queue_index) in qemu_get_peer() argument
379 assert(nc != NULL); in qemu_get_peer()
380 NetClientState *ncs = nc + queue_index; in qemu_get_peer()
384 static void qemu_cleanup_net_client(NetClientState *nc) in qemu_cleanup_net_client() argument
386 QTAILQ_REMOVE(&net_clients, nc, next); in qemu_cleanup_net_client()
388 if (nc->info->cleanup) { in qemu_cleanup_net_client()
389 nc->info->cleanup(nc); in qemu_cleanup_net_client()
393 static void qemu_free_net_client(NetClientState *nc) in qemu_free_net_client() argument
395 if (nc->incoming_queue) { in qemu_free_net_client()
396 qemu_del_net_queue(nc->incoming_queue); in qemu_free_net_client()
398 if (nc->peer) { in qemu_free_net_client()
399 nc->peer->peer = NULL; in qemu_free_net_client()
401 g_free(nc->name); in qemu_free_net_client()
402 g_free(nc->model); in qemu_free_net_client()
403 if (nc->destructor) { in qemu_free_net_client()
404 nc->destructor(nc); in qemu_free_net_client()
408 void qemu_del_net_client(NetClientState *nc) in qemu_del_net_client() argument
414 assert(nc->info->type != NET_CLIENT_DRIVER_NIC); in qemu_del_net_client()
419 queues = qemu_find_net_clients_except(nc->name, ncs, in qemu_del_net_client()
424 QTAILQ_FOREACH_SAFE(nf, &nc->filters, next, next) { in qemu_del_net_client()
429 if (nc->peer && nc->peer->info->type == NET_CLIENT_DRIVER_NIC) { in qemu_del_net_client()
430 NICState *nic = qemu_get_nic(nc->peer); in qemu_del_net_client()
440 if (nc->peer->info->link_status_changed) { in qemu_del_net_client()
441 nc->peer->info->link_status_changed(nc->peer); in qemu_del_net_client()
464 NetClientState *nc = qemu_get_subqueue(nic, i); in qemu_del_nic() local
467 qemu_free_net_client(nc->peer); in qemu_del_nic()
468 } else if (nc->peer) { in qemu_del_nic()
470 qemu_purge_queued_packets(nc->peer); in qemu_del_nic()
475 NetClientState *nc = qemu_get_subqueue(nic, i); in qemu_del_nic() local
477 qemu_cleanup_net_client(nc); in qemu_del_nic()
478 qemu_free_net_client(nc); in qemu_del_nic()
486 NetClientState *nc; in qemu_foreach_nic() local
488 QTAILQ_FOREACH(nc, &net_clients, next) { in qemu_foreach_nic()
489 if (nc->info->type == NET_CLIENT_DRIVER_NIC) { in qemu_foreach_nic()
490 if (nc->queue_index == 0) { in qemu_foreach_nic()
491 func(qemu_get_nic(nc), opaque); in qemu_foreach_nic()
497 bool qemu_has_ufo(NetClientState *nc) in qemu_has_ufo() argument
499 if (!nc || !nc->info->has_ufo) { in qemu_has_ufo()
503 return nc->info->has_ufo(nc); in qemu_has_ufo()
506 bool qemu_has_uso(NetClientState *nc) in qemu_has_uso() argument
508 if (!nc || !nc->info->has_uso) { in qemu_has_uso()
512 return nc->info->has_uso(nc); in qemu_has_uso()
515 bool qemu_has_vnet_hdr(NetClientState *nc) in qemu_has_vnet_hdr() argument
517 if (!nc || !nc->info->has_vnet_hdr) { in qemu_has_vnet_hdr()
521 return nc->info->has_vnet_hdr(nc); in qemu_has_vnet_hdr()
524 bool qemu_has_vnet_hdr_len(NetClientState *nc, int len) in qemu_has_vnet_hdr_len() argument
526 if (!nc || !nc->info->has_vnet_hdr_len) { in qemu_has_vnet_hdr_len()
530 return nc->info->has_vnet_hdr_len(nc, len); in qemu_has_vnet_hdr_len()
533 void qemu_set_offload(NetClientState *nc, int csum, int tso4, int tso6, in qemu_set_offload() argument
536 if (!nc || !nc->info->set_offload) { in qemu_set_offload()
540 nc->info->set_offload(nc, csum, tso4, tso6, ecn, ufo, uso4, uso6); in qemu_set_offload()
543 int qemu_get_vnet_hdr_len(NetClientState *nc) in qemu_get_vnet_hdr_len() argument
545 if (!nc) { in qemu_get_vnet_hdr_len()
549 return nc->vnet_hdr_len; in qemu_get_vnet_hdr_len()
552 void qemu_set_vnet_hdr_len(NetClientState *nc, int len) in qemu_set_vnet_hdr_len() argument
554 if (!nc || !nc->info->set_vnet_hdr_len) { in qemu_set_vnet_hdr_len()
562 nc->vnet_hdr_len = len; in qemu_set_vnet_hdr_len()
563 nc->info->set_vnet_hdr_len(nc, len); in qemu_set_vnet_hdr_len()
566 int qemu_set_vnet_le(NetClientState *nc, bool is_le) in qemu_set_vnet_le() argument
569 if (!nc || !nc->info->set_vnet_le) { in qemu_set_vnet_le()
573 return nc->info->set_vnet_le(nc, is_le); in qemu_set_vnet_le()
579 int qemu_set_vnet_be(NetClientState *nc, bool is_be) in qemu_set_vnet_be() argument
584 if (!nc || !nc->info->set_vnet_be) { in qemu_set_vnet_be()
588 return nc->info->set_vnet_be(nc, is_be); in qemu_set_vnet_be()
592 int qemu_can_receive_packet(NetClientState *nc) in qemu_can_receive_packet() argument
594 if (nc->receive_disabled) { in qemu_can_receive_packet()
596 } else if (nc->info->can_receive && in qemu_can_receive_packet()
597 !nc->info->can_receive(nc)) { in qemu_can_receive_packet()
618 static ssize_t filter_receive_iov(NetClientState *nc, in filter_receive_iov() argument
630 QTAILQ_FOREACH(nf, &nc->filters, next) { in filter_receive_iov()
638 QTAILQ_FOREACH_REVERSE(nf, &nc->filters, next) { in filter_receive_iov()
650 static ssize_t filter_receive(NetClientState *nc, in filter_receive() argument
663 return filter_receive_iov(nc, direction, sender, flags, &iov, 1, sent_cb); in filter_receive()
666 void qemu_purge_queued_packets(NetClientState *nc) in qemu_purge_queued_packets() argument
668 if (!nc->peer) { in qemu_purge_queued_packets()
672 qemu_net_queue_purge(nc->peer->incoming_queue, nc); in qemu_purge_queued_packets()
675 void qemu_flush_or_purge_queued_packets(NetClientState *nc, bool purge) in qemu_flush_or_purge_queued_packets() argument
677 nc->receive_disabled = 0; in qemu_flush_or_purge_queued_packets()
679 if (nc->peer && nc->peer->info->type == NET_CLIENT_DRIVER_HUBPORT) { in qemu_flush_or_purge_queued_packets()
680 if (net_hub_flush(nc->peer)) { in qemu_flush_or_purge_queued_packets()
684 if (qemu_net_queue_flush(nc->incoming_queue)) { in qemu_flush_or_purge_queued_packets()
691 qemu_net_queue_purge(nc->incoming_queue, nc->peer); in qemu_flush_or_purge_queued_packets()
695 void qemu_flush_queued_packets(NetClientState *nc) in qemu_flush_queued_packets() argument
697 qemu_flush_or_purge_queued_packets(nc, false); in qemu_flush_queued_packets()
743 ssize_t qemu_send_packet(NetClientState *nc, const uint8_t *buf, int size) in qemu_send_packet() argument
745 return qemu_send_packet_async(nc, buf, size, NULL); in qemu_send_packet()
748 ssize_t qemu_receive_packet(NetClientState *nc, const uint8_t *buf, int size) in qemu_receive_packet() argument
750 if (!qemu_can_receive_packet(nc)) { in qemu_receive_packet()
754 return qemu_net_queue_receive(nc->incoming_queue, buf, size); in qemu_receive_packet()
757 ssize_t qemu_send_packet_raw(NetClientState *nc, const uint8_t *buf, int size) in qemu_send_packet_raw() argument
759 return qemu_send_packet_async_with_flags(nc, QEMU_NET_PACKET_FLAG_RAW, in qemu_send_packet_raw()
763 static ssize_t nc_sendv_compat(NetClientState *nc, const struct iovec *iov, in nc_sendv_compat() argument
784 ret = nc->info->receive(nc, buffer, offset); in nc_sendv_compat()
797 NetClientState *nc = opaque; in qemu_deliver_packet_iov() local
803 if (nc->link_down) { in qemu_deliver_packet_iov()
807 if (nc->receive_disabled) { in qemu_deliver_packet_iov()
811 if (nc->info->type != NET_CLIENT_DRIVER_NIC || in qemu_deliver_packet_iov()
812 qemu_get_nic(nc)->reentrancy_guard->engaged_in_io) { in qemu_deliver_packet_iov()
815 owned_reentrancy_guard = qemu_get_nic(nc)->reentrancy_guard; in qemu_deliver_packet_iov()
819 if ((flags & QEMU_NET_PACKET_FLAG_RAW) && nc->vnet_hdr_len) { in qemu_deliver_packet_iov()
822 iov_copy[0].iov_len = nc->vnet_hdr_len; in qemu_deliver_packet_iov()
827 if (nc->info->receive_iov) { in qemu_deliver_packet_iov()
828 ret = nc->info->receive_iov(nc, iov, iovcnt); in qemu_deliver_packet_iov()
830 ret = nc_sendv_compat(nc, iov, iovcnt, flags); in qemu_deliver_packet_iov()
838 nc->receive_disabled = 1; in qemu_deliver_packet_iov()
881 qemu_sendv_packet(NetClientState *nc, const struct iovec *iov, int iovcnt) in qemu_sendv_packet() argument
883 return qemu_sendv_packet_async(nc, iov, iovcnt, NULL); in qemu_sendv_packet()
888 NetClientState *nc; in qemu_find_netdev() local
890 QTAILQ_FOREACH(nc, &net_clients, next) { in qemu_find_netdev()
891 if (nc->info->type == NET_CLIENT_DRIVER_NIC) in qemu_find_netdev()
893 if (!strcmp(nc->name, id)) { in qemu_find_netdev()
894 return nc; in qemu_find_netdev()
904 NetClientState *nc; in qemu_find_net_clients_except() local
907 QTAILQ_FOREACH(nc, &net_clients, next) { in qemu_find_net_clients_except()
908 if (nc->info->type == type) { in qemu_find_net_clients_except()
911 if (!id || !strcmp(nc->name, id)) { in qemu_find_net_clients_except()
913 ncs[ret] = nc; in qemu_find_net_clients_except()
1280 NetClientState *nc; in net_client_init1() local
1312 nc = qemu_find_netdev(netdev->id); in net_client_init1()
1313 if (nc) { in net_client_init1()
1328 nc = qemu_find_netdev(netdev->id); in net_client_init1()
1329 assert(nc); in net_client_init1()
1330 nc->is_netdev = true; in net_client_init1()
1454 NetClientState *nc; in qmp_netdev_del() local
1457 nc = qemu_find_netdev(id); in qmp_netdev_del()
1458 if (!nc) { in qmp_netdev_del()
1464 if (!nc->is_netdev) { in qmp_netdev_del()
1469 qemu_del_net_client(nc); in qmp_netdev_del()
1505 void print_net_client(Monitor *mon, NetClientState *nc) in print_net_client() argument
1509 monitor_printf(mon, "%s: index=%d,type=%s,%s\n", nc->name, in print_net_client()
1510 nc->queue_index, in print_net_client()
1511 NetClientDriver_str(nc->info->type), in print_net_client()
1512 nc->info_str); in print_net_client()
1513 if (!QTAILQ_EMPTY(&nc->filters)) { in print_net_client()
1516 QTAILQ_FOREACH(nf, &nc->filters, next) { in print_net_client()
1526 NetClientState *nc; in qmp_query_rx_filter() local
1529 QTAILQ_FOREACH(nc, &net_clients, next) { in qmp_query_rx_filter()
1532 if (name && strcmp(nc->name, name) != 0) { in qmp_query_rx_filter()
1537 if (nc->info->type != NET_CLIENT_DRIVER_NIC) { in qmp_query_rx_filter()
1549 if (nc->queue_index != 0) in qmp_query_rx_filter()
1552 if (nc->info->query_rx_filter) { in qmp_query_rx_filter()
1553 info = nc->info->query_rx_filter(nc); in qmp_query_rx_filter()
1576 NetClientState *nc; in colo_notify_filters_event() local
1581 QTAILQ_FOREACH(nc, &net_clients, next) { in colo_notify_filters_event()
1582 QTAILQ_FOREACH(nf, &nc->filters, next) { in colo_notify_filters_event()
1596 NetClientState *nc; in qmp_set_link() local
1608 nc = ncs[0]; in qmp_set_link()
1614 if (nc->info->link_status_changed) { in qmp_set_link()
1615 nc->info->link_status_changed(nc); in qmp_set_link()
1618 if (nc->peer) { in qmp_set_link()
1627 if (nc->peer->info->type == NET_CLIENT_DRIVER_NIC) { in qmp_set_link()
1632 if (nc->peer->info->link_status_changed) { in qmp_set_link()
1633 nc->peer->info->link_status_changed(nc->peer); in qmp_set_link()
1641 NetClientState *nc; in net_vm_change_state_handler() local
1644 QTAILQ_FOREACH_SAFE(nc, &net_clients, next, tmp) { in net_vm_change_state_handler()
1647 if (nc->peer && qemu_can_send_packet(nc)) { in net_vm_change_state_handler()
1648 qemu_flush_queued_packets(nc->peer); in net_vm_change_state_handler()
1654 qemu_flush_or_purge_queued_packets(nc, true); in net_vm_change_state_handler()
1661 NetClientState *nc, **p = &QTAILQ_FIRST(&net_clients); in net_cleanup() local
1680 * The 'nc' variable isn't part of the list traversal; it's purely in net_cleanup()
1685 nc = *p; in net_cleanup()
1686 if (nc->info->type == NET_CLIENT_DRIVER_NIC) { in net_cleanup()
1688 p = &QTAILQ_NEXT(nc, next); in net_cleanup()
1690 qemu_del_net_client(nc); in net_cleanup()
1699 NetClientState *nc; in net_check_clients() local
1708 QTAILQ_FOREACH(nc, &net_clients, next) { in net_check_clients()
1709 if (!nc->peer) { in net_check_clients()
1711 nc->info->type == NET_CLIENT_DRIVER_NIC in net_check_clients()
1713 nc->name); in net_check_clients()