X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=examples%2Fethtool%2Fethtool-app%2Fmain.c;h=7383413215d69787f1fdc8ab5d6d310b1b411c86;hb=611faa5f46cc67449f272e14450fc6a0a275767d;hp=c1815bb9466be171aa57ea56c56b20b8525ac716;hpb=d9a42a69febf453cdb735e77fc0e01463ddf4acc;p=dpdk.git diff --git a/examples/ethtool/ethtool-app/main.c b/examples/ethtool/ethtool-app/main.c index c1815bb946..7383413215 100644 --- a/examples/ethtool/ethtool-app/main.c +++ b/examples/ethtool/ethtool-app/main.c @@ -32,7 +32,7 @@ struct txq_port { }; struct app_port { - struct ether_addr mac_addr; + struct rte_ether_addr mac_addr; struct txq_port txq; rte_spinlock_t lock; int port_active; @@ -95,16 +95,20 @@ static void setup_ports(struct app_config *app_cfg, int cnt_ports) char str_name[16]; uint16_t nb_rxd = PORT_RX_QUEUE_SIZE; uint16_t nb_txd = PORT_TX_QUEUE_SIZE; - struct rte_eth_txconf txconf; + int ret; memset(&cfg_port, 0, sizeof(cfg_port)); cfg_port.txmode.mq_mode = ETH_MQ_TX_NONE; - cfg_port.rxmode.ignore_offload_bitfield = 1; for (idx_port = 0; idx_port < cnt_ports; idx_port++) { struct app_port *ptr_port = &app_cfg->ports[idx_port]; - rte_eth_dev_info_get(idx_port, &dev_info); + ret = rte_eth_dev_info_get(idx_port, &dev_info); + if (ret != 0) + rte_exit(EXIT_FAILURE, + "Error during getting device (port %u) info: %s\n", + idx_port, strerror(-ret)); + size_pktpool = dev_info.rx_desc_lim.nb_max + dev_info.tx_desc_lim.nb_max + PKTPOOL_EXTRA_SIZE; @@ -141,11 +145,9 @@ static void setup_ports(struct app_config *app_cfg, int cnt_ports) rte_exit(EXIT_FAILURE, "rte_eth_rx_queue_setup failed" ); - txconf = dev_info.default_txconf; - txconf.txq_flags = ETH_TXQ_FLAGS_IGNORE; if (rte_eth_tx_queue_setup( idx_port, 0, nb_txd, - rte_eth_dev_socket_id(idx_port), &txconf) < 0) + rte_eth_dev_socket_id(idx_port), NULL) < 0) rte_exit(EXIT_FAILURE, "rte_eth_tx_queue_setup failed" ); @@ -154,7 +156,12 @@ static void setup_ports(struct app_config *app_cfg, int cnt_ports) "%s:%i: rte_eth_dev_start failed", __FILE__, __LINE__ ); - rte_eth_macaddr_get(idx_port, &ptr_port->mac_addr); + ret = rte_eth_macaddr_get(idx_port, &ptr_port->mac_addr); + if (ret != 0) + rte_exit(EXIT_FAILURE, + "rte_eth_macaddr_get failed (port %u): %s\n", + idx_port, rte_strerror(-ret)); + rte_spinlock_init(&ptr_port->lock); } } @@ -162,14 +169,14 @@ static void setup_ports(struct app_config *app_cfg, int cnt_ports) static void process_frame(struct app_port *ptr_port, struct rte_mbuf *ptr_frame) { - struct ether_hdr *ptr_mac_hdr; + struct rte_ether_hdr *ptr_mac_hdr; - ptr_mac_hdr = rte_pktmbuf_mtod(ptr_frame, struct ether_hdr *); - ether_addr_copy(&ptr_mac_hdr->s_addr, &ptr_mac_hdr->d_addr); - ether_addr_copy(&ptr_port->mac_addr, &ptr_mac_hdr->s_addr); + ptr_mac_hdr = rte_pktmbuf_mtod(ptr_frame, struct rte_ether_hdr *); + rte_ether_addr_copy(&ptr_mac_hdr->s_addr, &ptr_mac_hdr->d_addr); + rte_ether_addr_copy(&ptr_port->mac_addr, &ptr_mac_hdr->s_addr); } -static int slave_main(__attribute__((unused)) void *ptr_data) +static int slave_main(__rte_unused void *ptr_data) { struct app_port *ptr_port; struct rte_mbuf *ptr_frame; @@ -180,6 +187,7 @@ static int slave_main(__attribute__((unused)) void *ptr_data) uint16_t cnt_sent; uint16_t idx_port; uint16_t lock_result; + int ret; while (app_cfg.exit_now == 0) { for (idx_port = 0; idx_port < app_cfg.cnt_ports; idx_port++) { @@ -196,8 +204,16 @@ static int slave_main(__attribute__((unused)) void *ptr_data) /* MAC address was updated */ if (ptr_port->port_dirty == 1) { - rte_eth_macaddr_get(ptr_port->idx_port, + ret = rte_eth_macaddr_get(ptr_port->idx_port, &ptr_port->mac_addr); + if (ret != 0) { + rte_spinlock_unlock(&ptr_port->lock); + printf("Failed to get MAC address (port %u): %s", + ptr_port->idx_port, + rte_strerror(-ret)); + return ret; + } + ptr_port->port_dirty = 0; }