diff --git a/dpdk-iface-kmod/dpdk_iface.h b/dpdk-iface-kmod/dpdk_iface.h index a498685..a9264fa 100644 --- a/dpdk-iface-kmod/dpdk_iface.h +++ b/dpdk-iface-kmod/dpdk_iface.h @@ -142,11 +142,11 @@ static const struct net_device_ops netdev_ops = { .ndo_open = netdev_open, .ndo_stop = netdev_open, .ndo_start_xmit = netdev_xmit, - .ndo_set_rx_mode = netdev_no_ret, + .ndo_set_rx_mode = (void*)netdev_no_ret, .ndo_validate_addr = netdev_open, .ndo_set_mac_address = NULL, .ndo_change_mtu = NULL, - .ndo_tx_timeout = netdev_no_ret, + .ndo_tx_timeout = (void*)netdev_no_ret, .ndo_vlan_rx_add_vid = NULL, .ndo_vlan_rx_kill_vid = NULL, .ndo_do_ioctl = NULL, @@ -162,7 +162,7 @@ static const struct net_device_ops netdev_ops = { .ndo_get_stats = netdev_stats, .ndo_setup_tc = NULL, #ifdef CONFIG_NET_POLL_CONTROLLER - .ndo_poll_controller = netdev_no_ret, + .ndo_poll_controller = (void*)netdev_no_ret, .ndo_netpoll_setup = NULL, .ndo_netpoll_cleanup = NULL, #endif diff --git a/mtcp/src/Makefile.in b/mtcp/src/Makefile.in index f81a0c8..2f0e5da 100644 --- a/mtcp/src/Makefile.in +++ b/mtcp/src/Makefile.in @@ -41,7 +41,7 @@ endif # DBGCERR = Enable macro to print error statements # -GCC_OPT += -Wall -fPIC -fgnu89-inline -Werror +GCC_OPT += -Wall -fPIC -fgnu89-inline -Werror -Wno-error=stringop-truncation -Wno-error=address-of-packed-member #DBG_OPT = -DDBGMSG -DDBGFUNC -DSTREAM -DSTATE -DTSTAT -DAPP -DEPOLL #DBG_OPT = -DDBGMSG -DDBGFUNC -DSTREAM -DSTATE #DBG_OPT += -DPKTDUMP diff --git a/mtcp/src/config.c b/mtcp/src/config.c index 38188bd..2b56d2a 100644 --- a/mtcp/src/config.c +++ b/mtcp/src/config.c @@ -74,7 +74,7 @@ mystrtol(const char *nptr, int base) exit(EXIT_FAILURE); } if (endptr == nptr) { - TRACE_CONFIG("Parsing strtol error!\n"); + TRACE_CONFIG("Parsing strtol error! %s\n", nptr); exit(EXIT_FAILURE); } @@ -632,6 +632,8 @@ ParseConfiguration(char *line) SaveInterfaceInfo(q); else SaveInterfaceInfo(line + strlen(p) + 1); + } else if (strncmp(p, "local_ip", 8) == 0) { + } else if (strcmp(p, "io") == 0) { AssignIOModule(q); if (CheckIOModuleAccessPermissions() == -1) { diff --git a/mtcp/src/dpdk_module.c b/mtcp/src/dpdk_module.c index 76d6da8..b32249e 100644 --- a/mtcp/src/dpdk_module.c +++ b/mtcp/src/dpdk_module.c @@ -691,8 +691,8 @@ dpdk_load_module(void) MEMPOOL_F_SC_GET); if (pktmbuf_pool[rxlcore_id] == NULL) - rte_exit(EXIT_FAILURE, "Cannot init mbuf pool, errno: %d\n", - rte_errno); + rte_exit(EXIT_FAILURE, "Cannot init mbuf pool, errno: %d, error: %s\n", + rte_errno, rte_strerror(rte_errno)); } /* Initialise each port */ diff --git a/mtcp/src/io_module.c b/mtcp/src/io_module.c index 198a988..4f11ba0 100644 --- a/mtcp/src/io_module.c +++ b/mtcp/src/io_module.c @@ -98,74 +98,12 @@ GetNumQueues() } #endif /* !PSIO */ /*----------------------------------------------------------------------------*/ -#ifndef DISABLE_DPDK -/** - * returns max numa ID while probing for rte devices - */ -static int -probe_all_rte_devices(char **argv, int *argc, char *dev_name_list) -{ - PciDevice pd; - int fd, numa_id = -1; - static char end[] = ""; - static const char delim[] = " \t"; - static char *dev_tokenizer; - char *dev_token, *saveptr; - - dev_tokenizer = strdup(dev_name_list); - if (dev_tokenizer == NULL) { - TRACE_ERROR("Can't allocate memory for dev_tokenizer!\n"); - exit(EXIT_FAILURE); - } - fd = open(DEV_PATH, O_RDONLY); - if (fd != -1) { - dev_token = strtok_r(dev_tokenizer, delim, &saveptr); - while (dev_token != NULL) { - strcpy(pd.ifname, dev_token); - if (ioctl(fd, FETCH_PCI_ADDRESS, &pd) == -1) { - TRACE_DBG("Could not find pci info on dpdk " - "device: %s. Is it a dpdk-attached " - "interface?\n", dev_token); - goto loop_over; - } - argv[*argc] = strdup("-w"); - argv[*argc + 1] = calloc(PCI_LENGTH, 1); - if (argv[*argc] == NULL || - argv[*argc + 1] == NULL) { - TRACE_ERROR("Memory allocation error!\n"); - exit(EXIT_FAILURE); - } - sprintf(argv[*argc + 1], PCI_DOM":"PCI_BUS":" - PCI_DEVICE"."PCI_FUNC, - pd.pa.domain, pd.pa.bus, pd.pa.device, - pd.pa.function); - *argc += 2; - if (pd.numa_socket > numa_id) numa_id = pd.numa_socket; - loop_over: - dev_token = strtok_r(NULL, delim, &saveptr); - } - close(fd); - free(dev_tokenizer); - } else { - TRACE_ERROR("Error opening dpdk-face!\n"); - exit(EXIT_FAILURE); - } - - /* add the terminating "" sequence */ - argv[*argc] = end; - - return numa_id; -} -#endif /* !DISABLE_DPDK */ -/*----------------------------------------------------------------------------*/ int SetNetEnv(char *dev_name_list, char *port_stat_list) { int eidx = 0; int i, j; - int set_all_inf = (strncmp(dev_name_list, ALL_STRING, sizeof(ALL_STRING))==0); - TRACE_CONFIG("Loading interface setting\n"); CONFIG.eths = (struct eth_table *) @@ -177,6 +115,7 @@ SetNetEnv(char *dev_name_list, char *port_stat_list) if (current_iomodule_func == &ps_module_func) { #ifndef DISABLE_PSIO + int set_all_inf = (strncmp(dev_name_list, ALL_STRING, sizeof(ALL_STRING))==0); struct ifreq ifr; /* calculate num_devices now! */ num_devices = ps_list_devices(devices); @@ -260,11 +199,6 @@ SetNetEnv(char *dev_name_list, char *port_stat_list) char socket_mem_str[32] = ""; // int i; int ret, socket_mem; -#if RTE_VERSION < RTE_VERSION_NUM(19, 8, 0, 0) - static struct ether_addr ports_eth_addr[RTE_MAX_ETHPORTS]; -#else - static struct rte_ether_addr ports_eth_addr[RTE_MAX_ETHPORTS]; -#endif /* STEP 1: first determine CPU mask */ mpz_init(_cpumask); @@ -315,7 +249,6 @@ SetNetEnv(char *dev_name_list, char *port_stat_list) #endif "--proc-type=auto" }; - ret = probe_all_rte_devices(argv, &argc, dev_name_list); /* STEP 4: build up socket mem parameter */ @@ -350,6 +283,7 @@ SetNetEnv(char *dev_name_list, char *port_stat_list) TRACE_ERROR("Invalid EAL args!\n"); exit(EXIT_FAILURE); } + /* give me the count of 'detected' ethernet ports */ #if RTE_VERSION < RTE_VERSION_NUM(18, 5, 0, 0) num_devices = rte_eth_dev_count(); @@ -361,84 +295,38 @@ SetNetEnv(char *dev_name_list, char *port_stat_list) exit(EXIT_FAILURE); } - /* get mac addr entries of 'detected' dpdk ports */ - for (ret = 0; ret < num_devices; ret++) - rte_eth_macaddr_get(ret, &ports_eth_addr[ret]); - num_queues = MIN(CONFIG.num_cores, MAX_CPUS); - struct ifaddrs *ifap; - struct ifaddrs *iter_if; - char *seek; - - if (getifaddrs(&ifap) != 0) { - perror("getifaddrs: "); - exit(EXIT_FAILURE); + uint16_t port_id = 0; + const char *port_name = "0000:05:00.1"; + if (rte_eth_dev_get_port_by_name(port_name, &port_id) == 0) { + eidx = CONFIG.eths_num++; + strcpy(CONFIG.eths[eidx].dev_name, port_name); + CONFIG.eths[eidx].ifindex = port_id; + inet_aton("192.168.7.2", (struct in_addr*)&CONFIG.eths[eidx].ip_addr); + inet_aton("255.255.255.0", (struct in_addr*)&CONFIG.eths[eidx].netmask); +#if RTE_VERSION < RTE_VERSION_NUM(19, 8, 0, 0) + static struct ether_addr port_haddr; +#else + static struct rte_ether_addr port_haddr; +#endif + assert(sizeof(port_haddr.addr_bytes) == ETH_ALEN); + rte_eth_macaddr_get(CONFIG.eths[eidx].ifindex, &port_haddr); + memcpy(CONFIG.eths[eidx].haddr, port_haddr.addr_bytes, ETH_ALEN); + /* add to attached devices */ + for (j = 0; j < num_devices_attached; j++) { + if (devices_attached[j] == CONFIG.eths[eidx].ifindex) { + break; + } + } + devices_attached[num_devices_attached] = CONFIG.eths[eidx].ifindex; + num_devices_attached++; + fprintf(stderr, "Total number of attached devices: %d\n", num_devices_attached); + fprintf(stderr, "Interface name: %s\n", port_name); + } else { + fprintf(stderr, "Interface %s not found\n", port_name); } - iter_if = ifap; - do { - if (iter_if->ifa_addr && iter_if->ifa_addr->sa_family == AF_INET && - !set_all_inf && - (seek=strstr(dev_name_list, iter_if->ifa_name)) != NULL && - /* check if the interface was not aliased */ - *(seek + strlen(iter_if->ifa_name)) != ':') { - struct ifreq ifr; - - /* Setting informations */ - eidx = CONFIG.eths_num++; - strcpy(CONFIG.eths[eidx].dev_name, iter_if->ifa_name); - strcpy(ifr.ifr_name, iter_if->ifa_name); - - /* Create socket */ - int sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP); - if (sock == -1) { - perror("socket"); - exit(EXIT_FAILURE); - } - - /* getting address */ - if (ioctl(sock, SIOCGIFADDR, &ifr) == 0 ) { - struct in_addr sin = ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr; - CONFIG.eths[eidx].ip_addr = *(uint32_t *)&sin; - } - - if (ioctl(sock, SIOCGIFHWADDR, &ifr) == 0 ) { - for (j = 0; j < ETH_ALEN; j ++) { - CONFIG.eths[eidx].haddr[j] = ifr.ifr_addr.sa_data[j]; - } - } - - /* Net MASK */ - if (ioctl(sock, SIOCGIFNETMASK, &ifr) == 0) { - struct in_addr sin = ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr; - CONFIG.eths[eidx].netmask = *(uint32_t *)&sin; - } - close(sock); - - for (j = 0; j < num_devices; j++) { - if (!memcmp(&CONFIG.eths[eidx].haddr[0], &ports_eth_addr[j], - ETH_ALEN)) - CONFIG.eths[eidx].ifindex = j; - } - - /* add to attached devices */ - for (j = 0; j < num_devices_attached; j++) { - if (devices_attached[j] == CONFIG.eths[eidx].ifindex) { - break; - } - } - devices_attached[num_devices_attached] = CONFIG.eths[eidx].ifindex; - num_devices_attached++; - fprintf(stderr, "Total number of attached devices: %d\n", - num_devices_attached); - fprintf(stderr, "Interface name: %s\n", - iter_if->ifa_name); - } - iter_if = iter_if->ifa_next; - } while (iter_if != NULL); - - freeifaddrs(ifap); #if 0 /* * XXX: It seems that there is a bug in the RTE SDK. @@ -464,6 +352,7 @@ SetNetEnv(char *dev_name_list, char *port_stat_list) #endif /* !DISABLE_DPDK */ } else if (current_iomodule_func == &netmap_module_func) { #ifndef DISABLE_NETMAP + int set_all_inf = (strncmp(dev_name_list, ALL_STRING, sizeof(ALL_STRING))==0); struct ifaddrs *ifap; struct ifaddrs *iter_if; char *seek; diff --git a/util/netlib.c b/util/netlib.c index 9256fe3..258b8db 100644 --- a/util/netlib.c +++ b/util/netlib.c @@ -251,7 +251,7 @@ mystrtol(const char *nptr, int base) exit(EXIT_FAILURE); } if (endptr == nptr) { - fprintf(stderr, "Parsing strtol error!\n"); + fprintf(stderr, "Parsing strtol error! %s\n", nptr); exit(EXIT_FAILURE); }