diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/bp_sim.h | 4 | ||||
-rw-r--r-- | src/internal_api/trex_platform_api.h | 11 | ||||
-rw-r--r-- | src/main_dpdk.cpp | 80 | ||||
-rw-r--r-- | src/main_dpdk.h | 11 | ||||
-rw-r--r-- | src/rpc-server/commands/trex_rpc_cmd_general.cpp | 24 | ||||
-rw-r--r-- | src/stateless/cp/trex_stateless_port.cpp | 16 | ||||
-rw-r--r-- | src/stateless/cp/trex_stateless_port.h | 2 |
7 files changed, 65 insertions, 83 deletions
diff --git a/src/bp_sim.h b/src/bp_sim.h index e1852da4..b1033496 100755 --- a/src/bp_sim.h +++ b/src/bp_sim.h @@ -764,7 +764,8 @@ public: enum trex_run_mode_e { RUN_MODE_INVALID, RUN_MODE_BATCH, - RUN_MODE_INTERACTIVE + RUN_MODE_INTERACTIVE, + RUN_MODE_DUMP_INFO, }; enum trex_learn_mode_e { @@ -837,6 +838,7 @@ public: std::string out_file; std::string prefix; + std::vector<std::string> dump_interfaces; CMacAddrCfg m_mac_addr[TREX_MAX_PORTS]; diff --git a/src/internal_api/trex_platform_api.h b/src/internal_api/trex_platform_api.h index 7a2a0c8a..a55e8cd7 100644 --- a/src/internal_api/trex_platform_api.h +++ b/src/internal_api/trex_platform_api.h @@ -111,13 +111,6 @@ public: IF_STAT_RX_BYTES_COUNT = 8, // Card support counting rx bytes }; - enum driver_speed_e { - SPEED_INVALID, - SPEED_1G, - SPEED_10G, - SPEED_40G, - }; - struct mac_cfg_st { uint8_t hw_macaddr[6]; uint8_t src_macaddr[6]; @@ -130,7 +123,7 @@ public: */ struct intf_info_st { std::string driver_name; - driver_speed_e speed; + uint32_t speed; mac_cfg_st mac_info; std::string pci_addr; int numa_node; @@ -228,7 +221,7 @@ public: virtual void get_interface_info(uint8_t interface_id, intf_info_st &info) const { info.driver_name = "TEST"; - info.speed = TrexPlatformApi::SPEED_10G; + info.speed = 10000; info.has_crc = true; info.numa_node = 0; diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp index 0ef83c02..f0320921 100644 --- a/src/main_dpdk.cpp +++ b/src/main_dpdk.cpp @@ -121,8 +121,6 @@ struct port_cfg_t; class CTRexExtendedDriverBase { public: - virtual TrexPlatformApi::driver_speed_e get_driver_speed(uint8_t port_id) = 0; - /* by default NIC driver adds CRC */ virtual bool has_crc_added() { return true; @@ -166,10 +164,6 @@ public: CTRexExtendedDriverBase1G(){ } - TrexPlatformApi::driver_speed_e get_driver_speed(uint8_t port_id) { - return TrexPlatformApi::SPEED_1G; - } - static CTRexExtendedDriverBase * create(){ return ( new CTRexExtendedDriverBase1G() ); } @@ -215,10 +209,6 @@ public: CGlobalInfo::m_options.preview.set_vm_one_queue_enable(true); } - TrexPlatformApi::driver_speed_e get_driver_speed(uint8_t port_id) { - return TrexPlatformApi::SPEED_1G; - } - virtual bool has_crc_added() { return false; } @@ -267,10 +257,6 @@ public: CTRexExtendedDriverBase10G(){ } - TrexPlatformApi::driver_speed_e get_driver_speed(uint8_t port_id) { - return TrexPlatformApi::SPEED_10G; - } - static CTRexExtendedDriverBase * create(){ return ( new CTRexExtendedDriverBase10G() ); } @@ -311,7 +297,6 @@ public: m_if_per_card = 4; } - TrexPlatformApi::driver_speed_e get_driver_speed(uint8_t port_id); static CTRexExtendedDriverBase * create(){ return ( new CTRexExtendedDriverBase40G() ); } @@ -514,6 +499,7 @@ enum { OPT_HELP, OPT_MODE_BATCH, OPT_MODE_INTERACTIVE, OPT_NODE_DUMP, + OPT_DUMP_INTERFACES, OPT_UT, OPT_FILE_OUT, OPT_REAL_TIME, @@ -581,6 +567,7 @@ static CSimpleOpt::SOption parser_options[] = { OPT_LIMT_NUM_OF_PORTS,"--limit-ports", SO_REQ_SEP }, { OPT_CORES , "-c", SO_REQ_SEP }, { OPT_NODE_DUMP , "-v", SO_REQ_SEP }, + { OPT_DUMP_INTERFACES , "--dump-interfaces", SO_MULTI }, { OPT_LATENCY , "-l", SO_REQ_SEP }, { OPT_DURATION , "-d", SO_REQ_SEP }, { OPT_PLATFORM_FACTOR , "-pm", SO_REQ_SEP }, @@ -776,6 +763,7 @@ static int parse_options(int argc, char *argv[], CParserOption* po, bool first_t bool latency_was_set=false; (void)latency_was_set; + char ** rgpszArg = NULL; int a=0; int node_dump=0; @@ -897,6 +885,19 @@ static int parse_options(int argc, char *argv[], CParserOption* po, bool first_t node_dump=1; po->preview.setFileWrite(false); break; + case OPT_DUMP_INTERFACES: + if (first_time) { + rgpszArg = args.MultiArg(1); + while (rgpszArg != NULL) { + po->dump_interfaces.push_back(rgpszArg[0]); + rgpszArg = args.MultiArg(1); + } + } + if (po->m_run_mode != CParserOption::RUN_MODE_INVALID) { + parse_err("Please specify single run mode"); + } + po->m_run_mode = CParserOption::RUN_MODE_DUMP_INFO; + break; case OPT_MBUF_FACTOR: sscanf(args.OptionArg(),"%f", &po->m_mbuf_factor); break; @@ -4891,9 +4892,17 @@ int update_dpdk_args(void){ global_dpdk_args_num = 7; /* add white list */ - for (int i=0; i<(int)global_platform_cfg_info.m_if_list.size(); i++) { - global_dpdk_args[global_dpdk_args_num++]=(char *)"-w"; - global_dpdk_args[global_dpdk_args_num++]=(char *)global_platform_cfg_info.m_if_list[i].c_str(); + if (lpop->m_run_mode == CParserOption::RUN_MODE_DUMP_INFO and lpop->dump_interfaces.size()) { + for (int i=0; i<(int)lpop->dump_interfaces.size(); i++) { + global_dpdk_args[global_dpdk_args_num++]=(char *)"-w"; + global_dpdk_args[global_dpdk_args_num++]=(char *)lpop->dump_interfaces[i].c_str(); + } + } + else { + for (int i=0; i<(int)global_platform_cfg_info.m_if_list.size(); i++) { + global_dpdk_args[global_dpdk_args_num++]=(char *)"-w"; + global_dpdk_args[global_dpdk_args_num++]=(char *)global_platform_cfg_info.m_if_list[i].c_str(); + } } @@ -4951,6 +4960,22 @@ int sim_load_list_of_cap_files(CParserOption * op){ return (0); } +void dump_interfaces_info() { + printf("Showing interfaces info.\n"); + uint8_t m_max_ports = rte_eth_dev_count(); + struct ether_addr mac_addr; + char mac_str[ETHER_ADDR_FMT_SIZE]; + struct rte_pci_addr pci_addr; + + for (uint8_t port_id=0; port_id<m_max_ports; port_id++) { + // PCI and MAC + pci_addr = rte_eth_devices[port_id].pci_dev->addr; + rte_eth_macaddr_get(port_id, &mac_addr); + ether_format_addr(mac_str, sizeof mac_str, &mac_addr); + printf("PCI: %04x:%02x:%02x.%d - MAC: %s\n", + pci_addr.domain, pci_addr.bus, pci_addr.devid, pci_addr.function, mac_str); + } +} int main_test(int argc , char * argv[]){ @@ -5015,7 +5040,10 @@ int main_test(int argc , char * argv[]){ printf(" You might need to run ./trex-cfg once \n"); rte_exit(EXIT_FAILURE, "Invalid EAL arguments\n"); } - + if (CGlobalInfo::m_options.m_run_mode == CParserOption::RUN_MODE_DUMP_INFO) { + dump_interfaces_info(); + exit(0); + } reorder_dpdk_ports(); time_init(); @@ -5593,17 +5621,6 @@ CFlowStatParser *CTRexExtendedDriverBase10G::get_flow_stat_parser() { return parser; } -//////////////////////////////////////////////////////////////////////////////// -TrexPlatformApi::driver_speed_e CTRexExtendedDriverBase40G::get_driver_speed(uint8_t port_id) { - CPhyEthIF *phy_if = &g_trex.m_ports[port_id]; - - if (phy_if->m_dev_info.speed_capa & ETH_LINK_SPEED_40G) { - return TrexPlatformApi::SPEED_40G; - } else { - return TrexPlatformApi::SPEED_10G; - } - } - void CTRexExtendedDriverBase40G::clear_extended_stats(CPhyEthIF * _if){ rte_eth_stats_reset(_if->get_port_id()); } @@ -6099,7 +6116,8 @@ TrexDpdkPlatformApi::get_interface_info(uint8_t interface_id, intf_info_st &info struct ether_addr rte_mac_addr; info.driver_name = CTRexExtendedDriverDb::Ins()->get_driver_name(); - info.speed = CTRexExtendedDriverDb::Ins()->get_drv()->get_driver_speed(interface_id); + g_trex.m_ports[interface_id].update_link_status_nowait(); + g_trex.m_ports[interface_id].get_link_speed(&info.speed); info.has_crc = CTRexExtendedDriverDb::Ins()->get_drv()->has_crc_added(); /* mac INFO */ diff --git a/src/main_dpdk.h b/src/main_dpdk.h index 91618071..935a27ea 100644 --- a/src/main_dpdk.h +++ b/src/main_dpdk.h @@ -90,6 +90,9 @@ class CPhyEthIF { bool is_link_up(){ return (m_link.link_status?true:false); } + void get_link_speed(uint32_t *link_speed){ + *link_speed = m_link.link_speed; + } void dump_link(FILE *fd); void disable_flow_control(); void set_promiscuous(bool enable); @@ -119,10 +122,8 @@ class CPhyEthIF { } void flush_dp_rx_queue(void); void flush_rx_queue(void); - int add_rx_flow_stat_rule(uint8_t port_id, uint16_t l3_type, uint8_t l4_proto - , uint8_t ipv6_next_h, uint16_t id) const; - int del_rx_flow_stat_rule(uint8_t port_id, uint16_t l3_type, uint8_t l4_proto - , uint8_t ipv6_next_h, uint16_t id) const; + int add_rx_flow_stat_rule(uint8_t type, uint16_t proto, uint16_t id); + int del_rx_flow_stat_rule(uint8_t type, uint16_t proto, uint16_t id); inline uint16_t tx_burst(uint16_t queue_id, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) { return rte_eth_tx_burst(m_port_id, queue_id, tx_pkts, nb_pkts); } @@ -154,9 +155,9 @@ class CPhyEthIF { const std::vector<std::pair<uint8_t, uint8_t>> & get_core_list(); private: + struct rte_eth_link m_link; uint8_t m_port_id; uint8_t m_rx_queue; - struct rte_eth_link m_link; uint64_t m_sw_try_tx_pkt; uint64_t m_sw_tx_drop_pkt; CBwMeasure m_bw_tx; diff --git a/src/rpc-server/commands/trex_rpc_cmd_general.cpp b/src/rpc-server/commands/trex_rpc_cmd_general.cpp index 21f64e2e..cd845fca 100644 --- a/src/rpc-server/commands/trex_rpc_cmd_general.cpp +++ b/src/rpc-server/commands/trex_rpc_cmd_general.cpp @@ -289,7 +289,7 @@ TrexRpcCmdGetSysInfo::_run(const Json::Value ¶ms, Json::Value &result) { section["ports"] = Json::arrayValue; for (int i = 0; i < main->get_port_count(); i++) { - TrexPlatformApi::driver_speed_e speed; + uint32_t speed; string driver; string hw_macaddr; string src_macaddr; @@ -325,27 +325,7 @@ TrexRpcCmdGetSysInfo::_run(const Json::Value ¶ms, Json::Value &result) { section["ports"][i]["rx"]["caps"].append("rx_bytes"); } section["ports"][i]["rx"]["counters"] = port->get_rx_count_num(); - - - switch (speed) { - case TrexPlatformApi::SPEED_1G: - section["ports"][i]["speed"] = 1; - break; - - case TrexPlatformApi::SPEED_10G: - section["ports"][i]["speed"] = 10; - break; - - case TrexPlatformApi::SPEED_40G: - section["ports"][i]["speed"] = 40; - break; - - default: - /* unknown value */ - section["ports"][i]["speed"] = 0; - break; - } - + section["ports"][i]["speed"] = (uint16_t) speed / 1000; } diff --git a/src/stateless/cp/trex_stateless_port.cpp b/src/stateless/cp/trex_stateless_port.cpp index 134d4c98..2a545c5f 100644 --- a/src/stateless/cp/trex_stateless_port.cpp +++ b/src/stateless/cp/trex_stateless_port.cpp @@ -573,7 +573,7 @@ TrexStatelessPort::get_max_stream_id() const { } void -TrexStatelessPort::get_properties(std::string &driver, TrexPlatformApi::driver_speed_e &speed) { +TrexStatelessPort::get_properties(std::string &driver, uint32_t &speed) { driver = m_api_info.driver_name; speed = m_api_info.speed; @@ -657,19 +657,7 @@ TrexStatelessPort::send_message_to_rx(TrexStatelessCpToRxMsgBase *msg) { uint64_t TrexStatelessPort::get_port_speed_bps() const { - switch (m_api_info.speed) { - case TrexPlatformApi::SPEED_1G: - return (1LLU * 1000 * 1000 * 1000); - - case TrexPlatformApi::SPEED_10G: - return (10LLU * 1000 * 1000 * 1000); - - case TrexPlatformApi::SPEED_40G: - return (40LLU * 1000 * 1000 * 1000); - - default: - return 0; - } + return (uint64_t) m_api_info.speed * 1000 * 1000; } static inline double diff --git a/src/stateless/cp/trex_stateless_port.h b/src/stateless/cp/trex_stateless_port.h index 7d976e46..ba86a279 100644 --- a/src/stateless/cp/trex_stateless_port.h +++ b/src/stateless/cp/trex_stateless_port.h @@ -256,7 +256,7 @@ public: * @param driver * @param speed */ - void get_properties(std::string &driver, TrexPlatformApi::driver_speed_e &speed); + void get_properties(std::string &driver, uint32_t &speed); |