virtio-net.c (da3e8a23492dbc13c4b70d90b6ae42970624e63a) | virtio-net.c (631b22ea206300f09b9d1bb9249169e0f0092639) |
---|---|
1/* 2 * Virtio Network Device 3 * 4 * Copyright IBM, Corp. 2007 5 * 6 * Authors: 7 * Anthony Liguori <aliguori@us.ibm.com> 8 * --- 432 unchanged lines hidden (view full) --- 441 442static void virtio_net_set_multiqueue(VirtIONet *n, int multiqueue); 443 444static uint32_t virtio_net_get_features(VirtIODevice *vdev, uint32_t features) 445{ 446 VirtIONet *n = VIRTIO_NET(vdev); 447 NetClientState *nc = qemu_get_queue(n->nic); 448 | 1/* 2 * Virtio Network Device 3 * 4 * Copyright IBM, Corp. 2007 5 * 6 * Authors: 7 * Anthony Liguori <aliguori@us.ibm.com> 8 * --- 432 unchanged lines hidden (view full) --- 441 442static void virtio_net_set_multiqueue(VirtIONet *n, int multiqueue); 443 444static uint32_t virtio_net_get_features(VirtIODevice *vdev, uint32_t features) 445{ 446 VirtIONet *n = VIRTIO_NET(vdev); 447 NetClientState *nc = qemu_get_queue(n->nic); 448 |
449 /* Firstly sync all virtio-net possible supported features */ 450 features |= n->host_features; 451 | |
452 virtio_add_feature(&features, VIRTIO_NET_F_MAC); 453 454 if (!peer_has_vnet_hdr(n)) { 455 virtio_clear_feature(&features, VIRTIO_NET_F_CSUM); 456 virtio_clear_feature(&features, VIRTIO_NET_F_HOST_TSO4); 457 virtio_clear_feature(&features, VIRTIO_NET_F_HOST_TSO6); 458 virtio_clear_feature(&features, VIRTIO_NET_F_HOST_ECN); 459 --- 847 unchanged lines hidden (view full) --- 1307 1308static void virtio_net_set_multiqueue(VirtIONet *n, int multiqueue) 1309{ 1310 VirtIODevice *vdev = VIRTIO_DEVICE(n); 1311 int i, max = multiqueue ? n->max_queues : 1; 1312 1313 n->multiqueue = multiqueue; 1314 | 449 virtio_add_feature(&features, VIRTIO_NET_F_MAC); 450 451 if (!peer_has_vnet_hdr(n)) { 452 virtio_clear_feature(&features, VIRTIO_NET_F_CSUM); 453 virtio_clear_feature(&features, VIRTIO_NET_F_HOST_TSO4); 454 virtio_clear_feature(&features, VIRTIO_NET_F_HOST_TSO6); 455 virtio_clear_feature(&features, VIRTIO_NET_F_HOST_ECN); 456 --- 847 unchanged lines hidden (view full) --- 1304 1305static void virtio_net_set_multiqueue(VirtIONet *n, int multiqueue) 1306{ 1307 VirtIODevice *vdev = VIRTIO_DEVICE(n); 1308 int i, max = multiqueue ? n->max_queues : 1; 1309 1310 n->multiqueue = multiqueue; 1311 |
1315 for (i = 2; i < n->max_queues * 2 + 1; i++) { | 1312 for (i = 2; i <= n->max_queues * 2 + 1; i++) { |
1316 virtio_del_queue(vdev, i); 1317 } 1318 1319 for (i = 1; i < max; i++) { 1320 n->vqs[i].rx_vq = virtio_add_queue(vdev, 256, virtio_net_handle_rx); 1321 if (n->vqs[i].tx_timer) { 1322 n->vqs[i].tx_vq = 1323 virtio_add_queue(vdev, 256, virtio_net_handle_tx_timer); --- 226 unchanged lines hidden (view full) --- 1550{ 1551 VirtIONet *n = VIRTIO_NET(vdev); 1552 NetClientState *nc = qemu_get_subqueue(n->nic, vq2q(idx)); 1553 assert(n->vhost_started); 1554 vhost_net_virtqueue_mask(get_vhost_net(nc->peer), 1555 vdev, idx, mask); 1556} 1557 | 1313 virtio_del_queue(vdev, i); 1314 } 1315 1316 for (i = 1; i < max; i++) { 1317 n->vqs[i].rx_vq = virtio_add_queue(vdev, 256, virtio_net_handle_rx); 1318 if (n->vqs[i].tx_timer) { 1319 n->vqs[i].tx_vq = 1320 virtio_add_queue(vdev, 256, virtio_net_handle_tx_timer); --- 226 unchanged lines hidden (view full) --- 1547{ 1548 VirtIONet *n = VIRTIO_NET(vdev); 1549 NetClientState *nc = qemu_get_subqueue(n->nic, vq2q(idx)); 1550 assert(n->vhost_started); 1551 vhost_net_virtqueue_mask(get_vhost_net(nc->peer), 1552 vdev, idx, mask); 1553} 1554 |
1558static void virtio_net_set_config_size(VirtIONet *n, uint32_t host_features) | 1555void virtio_net_set_config_size(VirtIONet *n, uint32_t host_features) |
1559{ 1560 int i, config_size = 0; 1561 virtio_add_feature(&host_features, VIRTIO_NET_F_MAC); 1562 for (i = 0; feature_sizes[i].flags != 0; i++) { 1563 if (host_features & feature_sizes[i].flags) { 1564 config_size = MAX(feature_sizes[i].end, config_size); 1565 } 1566 } --- 16 unchanged lines hidden (view full) --- 1583 1584static void virtio_net_device_realize(DeviceState *dev, Error **errp) 1585{ 1586 VirtIODevice *vdev = VIRTIO_DEVICE(dev); 1587 VirtIONet *n = VIRTIO_NET(dev); 1588 NetClientState *nc; 1589 int i; 1590 | 1556{ 1557 int i, config_size = 0; 1558 virtio_add_feature(&host_features, VIRTIO_NET_F_MAC); 1559 for (i = 0; feature_sizes[i].flags != 0; i++) { 1560 if (host_features & feature_sizes[i].flags) { 1561 config_size = MAX(feature_sizes[i].end, config_size); 1562 } 1563 } --- 16 unchanged lines hidden (view full) --- 1580 1581static void virtio_net_device_realize(DeviceState *dev, Error **errp) 1582{ 1583 VirtIODevice *vdev = VIRTIO_DEVICE(dev); 1584 VirtIONet *n = VIRTIO_NET(dev); 1585 NetClientState *nc; 1586 int i; 1587 |
1591 virtio_net_set_config_size(n, n->host_features); | |
1592 virtio_init(vdev, "virtio-net", VIRTIO_ID_NET, n->config_size); 1593 1594 n->max_queues = MAX(n->nic_conf.peers.queues, 1); 1595 if (n->max_queues * 2 + 1 > VIRTIO_PCI_QUEUE_MAX) { 1596 error_setg(errp, "Invalid number of queues (= %" PRIu32 "), " | 1588 virtio_init(vdev, "virtio-net", VIRTIO_ID_NET, n->config_size); 1589 1590 n->max_queues = MAX(n->nic_conf.peers.queues, 1); 1591 if (n->max_queues * 2 + 1 > VIRTIO_PCI_QUEUE_MAX) { 1592 error_setg(errp, "Invalid number of queues (= %" PRIu32 "), " |
1597 "must be a postive integer less than %d.", | 1593 "must be a positive integer less than %d.", |
1598 n->max_queues, (VIRTIO_PCI_QUEUE_MAX - 1) / 2); 1599 virtio_cleanup(vdev); 1600 return; 1601 } 1602 n->vqs = g_malloc0(sizeof(VirtIONetQueue) * n->max_queues); 1603 n->vqs[0].rx_vq = virtio_add_queue(vdev, 256, virtio_net_handle_rx); 1604 n->curr_queues = 1; 1605 n->vqs[0].n = n; --- 114 unchanged lines hidden (view full) --- 1720 */ 1721 n->config_size = sizeof(struct virtio_net_config); 1722 device_add_bootindex_property(obj, &n->nic_conf.bootindex, 1723 "bootindex", "/ethernet-phy@0", 1724 DEVICE(n), NULL); 1725} 1726 1727static Property virtio_net_properties[] = { | 1594 n->max_queues, (VIRTIO_PCI_QUEUE_MAX - 1) / 2); 1595 virtio_cleanup(vdev); 1596 return; 1597 } 1598 n->vqs = g_malloc0(sizeof(VirtIONetQueue) * n->max_queues); 1599 n->vqs[0].rx_vq = virtio_add_queue(vdev, 256, virtio_net_handle_rx); 1600 n->curr_queues = 1; 1601 n->vqs[0].n = n; --- 114 unchanged lines hidden (view full) --- 1716 */ 1717 n->config_size = sizeof(struct virtio_net_config); 1718 device_add_bootindex_property(obj, &n->nic_conf.bootindex, 1719 "bootindex", "/ethernet-phy@0", 1720 DEVICE(n), NULL); 1721} 1722 1723static Property virtio_net_properties[] = { |
1728 DEFINE_VIRTIO_NET_FEATURES(VirtIONet, host_features), | |
1729 DEFINE_NIC_PROPERTIES(VirtIONet, nic_conf), 1730 DEFINE_PROP_UINT32("x-txtimer", VirtIONet, net_conf.txtimer, 1731 TX_TIMER_INTERVAL), 1732 DEFINE_PROP_INT32("x-txburst", VirtIONet, net_conf.txburst, TX_BURST), 1733 DEFINE_PROP_STRING("tx", VirtIONet, net_conf.tx), 1734 DEFINE_PROP_END_OF_LIST(), 1735}; 1736 --- 36 unchanged lines hidden --- | 1724 DEFINE_NIC_PROPERTIES(VirtIONet, nic_conf), 1725 DEFINE_PROP_UINT32("x-txtimer", VirtIONet, net_conf.txtimer, 1726 TX_TIMER_INTERVAL), 1727 DEFINE_PROP_INT32("x-txburst", VirtIONet, net_conf.txburst, TX_BURST), 1728 DEFINE_PROP_STRING("tx", VirtIONet, net_conf.tx), 1729 DEFINE_PROP_END_OF_LIST(), 1730}; 1731 --- 36 unchanged lines hidden --- |