X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=examples%2Fl2fwd%2Fmain.c;h=281c6b7a3f80e73ea8a27eb78b1e305a5ea46ff0;hb=e53ed84acbbb853396bfd959815da7e141756ad2;hp=05532551a5431d08d5ce7b0aaa351d85a3e1387d;hpb=a7db3afce75346832059d8bfe54a8f81945fb213;p=dpdk.git diff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c index 05532551a5..281c6b7a3f 100644 --- a/examples/l2fwd/main.c +++ b/examples/l2fwd/main.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -44,6 +43,9 @@ static volatile bool force_quit; /* MAC updating enabled by default */ static int mac_updating = 1; +/* Ports set in promiscuous mode off by default. */ +static int promiscuous_on; + #define RTE_LOGTYPE_L2FWD RTE_LOGTYPE_USER1 #define MAX_PKT_BURST 32 @@ -95,7 +97,7 @@ static struct rte_eth_conf port_conf = { .split_hdr_size = 0, }, .txmode = { - .mq_mode = ETH_MQ_TX_NONE, + .mq_mode = RTE_ETH_MQ_TX_NONE, }, }; @@ -170,11 +172,11 @@ l2fwd_mac_updating(struct rte_mbuf *m, unsigned dest_portid) eth = rte_pktmbuf_mtod(m, struct rte_ether_hdr *); /* 02:00:00:00:00:xx */ - tmp = ð->d_addr.addr_bytes[0]; + tmp = ð->dst_addr.addr_bytes[0]; *((uint64_t *)tmp) = 0x000000000002 + ((uint64_t)dest_portid << 40); /* src addr */ - rte_ether_addr_copy(&l2fwd_ports_eth_addr[dest_portid], ð->s_addr); + rte_ether_addr_copy(&l2fwd_ports_eth_addr[dest_portid], ð->src_addr); } /* Simple forward. 8< */ @@ -307,8 +309,9 @@ l2fwd_launch_one_lcore(__rte_unused void *dummy) static void l2fwd_usage(const char *prgname) { - printf("%s [EAL options] -- -p PORTMASK [-q NQ]\n" + printf("%s [EAL options] -- -p PORTMASK [-P] [-q NQ]\n" " -p PORTMASK: hexadecimal bitmask of ports to configure\n" + " -P : Enable promiscuous mode\n" " -q NQ: number of queue (=ports) per lcore (default is 1)\n" " -T PERIOD: statistics will be refreshed each PERIOD seconds (0 to disable, 10 default, 86400 maximum)\n" " --no-mac-updating: Disable MAC addresses updating (enabled by default)\n" @@ -425,6 +428,7 @@ l2fwd_parse_timer_period(const char *q_arg) static const char short_options[] = "p:" /* portmask */ + "P" /* promiscuous */ "q:" /* number of queues */ "T:" /* timer period */ ; @@ -473,6 +477,9 @@ l2fwd_parse_args(int argc, char **argv) return -1; } break; + case 'P': + promiscuous_on = 1; + break; /* nqueue */ case 'q': @@ -606,7 +613,7 @@ check_all_ports_link_status(uint32_t port_mask) continue; } /* clear all_ports_up flag if any link down */ - if (link.link_status == ETH_LINK_DOWN) { + if (link.link_status == RTE_ETH_LINK_DOWN) { all_ports_up = 0; break; } @@ -792,9 +799,9 @@ main(int argc, char **argv) "Error during getting device (port %u) info: %s\n", portid, strerror(-ret)); - if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE) + if (dev_info.tx_offload_capa & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) local_port_conf.txmode.offloads |= - DEV_TX_OFFLOAD_MBUF_FAST_FREE; + RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE; /* Configure the number of queues for a port. */ ret = rte_eth_dev_configure(portid, 1, 1, &local_port_conf); if (ret < 0) @@ -872,12 +879,13 @@ main(int argc, char **argv) ret, portid); printf("done: \n"); - - ret = rte_eth_promiscuous_enable(portid); - if (ret != 0) - rte_exit(EXIT_FAILURE, - "rte_eth_promiscuous_enable:err=%s, port=%u\n", - rte_strerror(-ret), portid); + if (promiscuous_on) { + ret = rte_eth_promiscuous_enable(portid); + if (ret != 0) + rte_exit(EXIT_FAILURE, + "rte_eth_promiscuous_enable:err=%s, port=%u\n", + rte_strerror(-ret), portid); + } printf("Port %u, MAC address: " RTE_ETHER_ADDR_PRT_FMT "\n\n", portid,