| 1924 | }; |
| 1925 | |
| 1926 | static int |
| 1927 | eth_dev_tap_create(struct rte_vdev_device *vdev, const char *tap_name, |
| 1928 | char *remote_iface, struct rte_ether_addr *mac_addr, |
| 1929 | enum rte_tuntap_type type, int persist) |
| 1930 | { |
| 1931 | int numa_node = rte_socket_id(); |
| 1932 | struct rte_eth_dev *dev; |
| 1933 | struct pmd_internals *pmd; |
| 1934 | struct pmd_process_private *process_private; |
| 1935 | const char *tuntap_name = tuntap_types[type]; |
| 1936 | struct rte_eth_dev_data *data; |
| 1937 | struct ifreq ifr; |
| 1938 | int i; |
| 1939 | |
| 1940 | TAP_LOG(DEBUG, "%s device on numa %u", tuntap_name, rte_socket_id()); |
| 1941 | |
| 1942 | dev = rte_eth_vdev_allocate(vdev, sizeof(*pmd)); |
| 1943 | if (!dev) { |
| 1944 | TAP_LOG(ERR, "%s Unable to allocate device struct", |
| 1945 | tuntap_name); |
| 1946 | goto error_exit_nodev; |
| 1947 | } |
| 1948 | |
| 1949 | process_private = (struct pmd_process_private *) |
| 1950 | rte_zmalloc_socket(tap_name, sizeof(struct pmd_process_private), |
| 1951 | RTE_CACHE_LINE_SIZE, dev->device->numa_node); |
| 1952 | |
| 1953 | if (process_private == NULL) { |
| 1954 | TAP_LOG(ERR, "Failed to alloc memory for process private"); |
| 1955 | return -1; |
| 1956 | } |
| 1957 | pmd = dev->data->dev_private; |
| 1958 | dev->process_private = process_private; |
| 1959 | pmd->dev = dev; |
| 1960 | strlcpy(pmd->name, tap_name, sizeof(pmd->name)); |
| 1961 | pmd->type = type; |
| 1962 | pmd->ka_fd = -1; |
| 1963 | pmd->nlsk_fd = -1; |
| 1964 | pmd->gso_ctx_mp = NULL; |
| 1965 | |
| 1966 | pmd->ioctl_sock = socket(AF_INET, SOCK_DGRAM, 0); |
| 1967 | if (pmd->ioctl_sock == -1) { |
| 1968 | TAP_LOG(ERR, |
| 1969 | "%s Unable to get a socket for management: %s", |
| 1970 | tuntap_name, strerror(errno)); |
| 1971 | goto error_exit; |
| 1972 | } |
| 1973 | |
| 1974 | /* Allocate interrupt instance */ |
| 1975 | pmd->intr_handle = rte_intr_instance_alloc(RTE_INTR_INSTANCE_F_SHARED); |
| 1976 | if (pmd->intr_handle == NULL) { |
| 1977 | TAP_LOG(ERR, "Failed to allocate intr handle"); |
| 1978 | goto error_exit; |
| 1979 | } |
| 1980 | |
| 1981 | /* Setup some default values */ |
| 1982 | data = dev->data; |
| 1983 | data->dev_private = pmd; |
no test coverage detected