X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=examples%2Fvhost%2Fmain.c;h=959c0c2838b4585d831d3fb8b49f8067849c259e;hb=01817b10d27c8d1376210d4798bf504dffaa8ccd;hp=d7b34b3d411bc025f1049b8c3ba7a8b0d77d681a;hpb=35b2d13fd6fdcbd191f2a30d74648faeb1186c65;p=dpdk.git diff --git a/examples/vhost/main.c b/examples/vhost/main.c index d7b34b3d41..959c0c2838 100644 --- a/examples/vhost/main.c +++ b/examples/vhost/main.c @@ -92,7 +92,6 @@ static uint32_t enable_tx_csum; static uint32_t enable_tso; static int client_mode; -static int dequeue_zero_copy; static int builtin_net_driver; @@ -228,7 +227,14 @@ port_init(uint16_t port) uint16_t q; /* The max pool number from dev_info will be used to validate the pool number specified in cmd line */ - rte_eth_dev_info_get (port, &dev_info); + retval = rte_eth_dev_info_get(port, &dev_info); + if (retval != 0) { + RTE_LOG(ERR, VHOST_PORT, + "Error during getting device (port %u) info: %s\n", + port, strerror(-retval)); + + return retval; + } rxconf = &dev_info.default_rxconf; txconf = &dev_info.default_txconf; @@ -240,16 +246,6 @@ port_init(uint16_t port) rx_ring_size = RTE_TEST_RX_DESC_DEFAULT; tx_ring_size = RTE_TEST_TX_DESC_DEFAULT; - /* - * When dequeue zero copy is enabled, guest Tx used vring will be - * updated only when corresponding mbuf is freed. Thus, the nb_tx_desc - * (tx_ring_size here) must be small enough so that the driver will - * hit the free threshold easily and free mbufs timely. Otherwise, - * guest Tx vring would be starved. - */ - if (dequeue_zero_copy) - tx_ring_size = 64; - tx_rings = (uint16_t)rte_lcore_count(); /* Get port configuration. */ @@ -329,10 +325,24 @@ port_init(uint16_t port) return retval; } - if (promiscuous) - rte_eth_promiscuous_enable(port); + if (promiscuous) { + retval = rte_eth_promiscuous_enable(port); + if (retval != 0) { + RTE_LOG(ERR, VHOST_PORT, + "Failed to enable promiscuous mode on port %u: %s\n", + port, rte_strerror(-retval)); + return retval; + } + } + + retval = rte_eth_macaddr_get(port, &vmdq_ports_eth_addr[port]); + if (retval < 0) { + RTE_LOG(ERR, VHOST_PORT, + "Failed to get MAC address on port %u: %s\n", + port, rte_strerror(-retval)); + return retval; + } - rte_eth_macaddr_get(port, &vmdq_ports_eth_addr[port]); RTE_LOG(INFO, VHOST_PORT, "Max virtio devices supported: %u\n", num_devices); RTE_LOG(INFO, VHOST_PORT, "Port %u MAC: %02"PRIx8" %02"PRIx8" %02"PRIx8 " %02"PRIx8" %02"PRIx8" %02"PRIx8"\n", @@ -386,10 +396,7 @@ parse_portmask(const char *portmask) /* parse hexadecimal string */ pm = strtoul(portmask, &end, 16); if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0') || (errno != 0)) - return -1; - - if (pm == 0) - return -1; + return 0; return pm; @@ -439,8 +446,7 @@ us_vhost_usage(const char *prgname) " --socket-file: The path of the socket file.\n" " --tx-csum [0|1] disable/enable TX checksum offload.\n" " --tso [0|1] disable/enable TCP segment offload.\n" - " --client register a vhost-user socket as client mode.\n" - " --dequeue-zero-copy enables dequeue zero copy\n", + " --client register a vhost-user socket as client mode.\n", prgname); } @@ -465,7 +471,6 @@ us_vhost_parse_args(int argc, char **argv) {"tx-csum", required_argument, NULL, 0}, {"tso", required_argument, NULL, 0}, {"client", no_argument, &client_mode, 1}, - {"dequeue-zero-copy", no_argument, &dequeue_zero_copy, 1}, {"builtin-net-driver", no_argument, &builtin_net_driver, 1}, {NULL, 0, 0, 0}, }; @@ -858,15 +863,15 @@ get_psd_sum(void *l3_hdr, uint64_t ol_flags) { if (ol_flags & PKT_TX_IPV4) return rte_ipv4_phdr_cksum(l3_hdr, ol_flags); - else /* assume ethertype == RTE_ETHER_TYPE_IPv6 */ + else /* assume ethertype == RTE_ETHER_TYPE_IPV6 */ return rte_ipv6_phdr_cksum(l3_hdr, ol_flags); } static void virtio_tx_offload(struct rte_mbuf *m) { void *l3_hdr; - struct ipv4_hdr *ipv4_hdr = NULL; - struct tcp_hdr *tcp_hdr = NULL; + struct rte_ipv4_hdr *ipv4_hdr = NULL; + struct rte_tcp_hdr *tcp_hdr = NULL; struct rte_ether_hdr *eth_hdr = rte_pktmbuf_mtod(m, struct rte_ether_hdr *); @@ -878,7 +883,7 @@ static void virtio_tx_offload(struct rte_mbuf *m) m->ol_flags |= PKT_TX_IP_CKSUM; } - tcp_hdr = (struct tcp_hdr *)((char *)l3_hdr + m->l3_len); + tcp_hdr = (struct rte_tcp_hdr *)((char *)l3_hdr + m->l3_len); tcp_hdr->cksum = get_psd_sum(l3_hdr, m->ol_flags); } @@ -1313,6 +1318,8 @@ print_stats(__rte_unused void *arg) } printf("===================================================\n"); + + fflush(stdout); } return NULL; @@ -1490,9 +1497,6 @@ main(int argc, char *argv[]) if (client_mode) flags |= RTE_VHOST_USER_CLIENT; - if (dequeue_zero_copy) - flags |= RTE_VHOST_USER_DEQUEUE_ZERO_COPY; - /* Register vhost user driver to handle vhost messages. */ for (i = 0; i < nb_sockets; i++) { char *file = socket_files + i * PATH_MAX;