| 811 | } |
| 812 | |
| 813 | static int |
| 814 | new_device(int vid) |
| 815 | { |
| 816 | struct rte_eth_dev *eth_dev; |
| 817 | struct internal_list *list; |
| 818 | struct pmd_internal *internal; |
| 819 | struct rte_eth_conf *dev_conf; |
| 820 | unsigned i; |
| 821 | char ifname[PATH_MAX]; |
| 822 | #ifdef RTE_LIBRTE_VHOST_NUMA |
| 823 | int newnode; |
| 824 | #endif |
| 825 | |
| 826 | rte_vhost_get_ifname(vid, ifname, sizeof(ifname)); |
| 827 | list = find_internal_resource(ifname); |
| 828 | if (list == NULL) { |
| 829 | VHOST_LOG(INFO, "Invalid device name: %s\n", ifname); |
| 830 | return -1; |
| 831 | } |
| 832 | |
| 833 | eth_dev = list->eth_dev; |
| 834 | internal = eth_dev->data->dev_private; |
| 835 | dev_conf = ð_dev->data->dev_conf; |
| 836 | |
| 837 | #ifdef RTE_LIBRTE_VHOST_NUMA |
| 838 | newnode = rte_vhost_get_numa_node(vid); |
| 839 | if (newnode >= 0) |
| 840 | eth_dev->data->numa_node = newnode; |
| 841 | #endif |
| 842 | |
| 843 | if (rte_vhost_get_negotiated_features(vid, &internal->features)) { |
| 844 | VHOST_LOG(ERR, "Failed to get device features\n"); |
| 845 | return -1; |
| 846 | } |
| 847 | |
| 848 | internal->vid = vid; |
| 849 | if (rte_atomic32_read(&internal->started) == 1) { |
| 850 | queue_setup(eth_dev, internal); |
| 851 | if (dev_conf->intr_conf.rxq) |
| 852 | eth_vhost_configure_intr(eth_dev); |
| 853 | } |
| 854 | |
| 855 | for (i = 0; i < rte_vhost_get_vring_num(vid); i++) |
| 856 | rte_vhost_enable_guest_notification(vid, i, 0); |
| 857 | |
| 858 | rte_vhost_get_mtu(vid, ð_dev->data->mtu); |
| 859 | |
| 860 | eth_dev->data->dev_link.link_status = RTE_ETH_LINK_UP; |
| 861 | |
| 862 | vhost_dev_csum_configure(eth_dev); |
| 863 | |
| 864 | rte_atomic32_set(&internal->dev_attached, 1); |
| 865 | update_queuing_status(eth_dev, false); |
| 866 | |
| 867 | VHOST_LOG(INFO, "Vhost device %d created\n", vid); |
| 868 | |
| 869 | rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_INTR_LSC, NULL); |
| 870 |
nothing calls this directly
no test coverage detected