/**
 * get system info
 * 
 */
trex_rpc_cmd_rc_e
TrexRpcCmdGetSysInfo::_run(const Json::Value &params, Json::Value &result) {
    string hostname;

    TrexStateless * main = get_stateless_obj();

    Json::Value &section = result["result"];

    get_hostname(hostname);
    section["hostname"]  = hostname;

    section["uptime"] = TrexRpcServer::get_server_uptime();

    /* FIXME: core count */
    section["dp_core_count"] = main->get_dp_core_count();
    section["core_type"] = get_cpu_model();

    /* ports */
   

    section["port_count"] = main->get_port_count();

    section["ports"] = Json::arrayValue;

    for (int i = 0; i < main->get_port_count(); i++) {
        string driver;
        TrexPlatformApi::driver_speed_e speed;

        TrexStatelessPort *port = main->get_port_by_id(i);
        port->get_properties(driver, speed);

        section["ports"][i]["index"]   = i;

        section["ports"][i]["driver"]  = driver;

        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;
        }


    }

    return (TREX_RPC_CMD_OK);
}
/**
 * publish async data now (fast flush)
 * 
 */
trex_rpc_cmd_rc_e
TrexRpcPublishNow::_run(const Json::Value &params, Json::Value &result) {
    TrexStateless *main = get_stateless_obj();

    uint32_t key = parse_uint32(params, "key", result);

    main->get_platform_api()->publish_async_data_now(key);

    result["result"] = Json::objectValue;
    return (TREX_RPC_CMD_OK);

}
Esempio n. 3
0
void CFlowStatRuleMgr::create() {
    uint16_t num_counters, cap;
    TrexStateless *tstateless = get_stateless_obj();
    assert(tstateless);

    m_api = tstateless->get_platform_api();
    assert(m_api);
    m_api->get_interface_stat_info(0, num_counters, cap);
    m_api->get_port_num(m_num_ports);
    for (uint8_t port = 0; port < m_num_ports; port++) {
        assert(m_api->reset_hw_flow_stats(port) == 0);
    }
    m_ring_to_rx = CMsgIns::Ins()->getCpRx()->getRingCpToDp(0);
    assert(m_ring_to_rx);
    m_rx_core = get_rx_sl_core_obj();
    m_parser = m_api->get_flow_stat_parser();
    assert(m_parser);
    m_cap = cap;
}
/**
 * get system info
 *
 */
trex_rpc_cmd_rc_e
TrexRpcCmdGetSysInfo::_run(const Json::Value &params, Json::Value &result) {
    string hostname;

    TrexStateless * main = get_stateless_obj();

    Json::Value &section = result["result"];

    get_hostname(hostname);
    section["hostname"]  = hostname;

    section["uptime"] = TrexRpcServer::get_server_uptime();

    /* FIXME: core count */
    section["dp_core_count"] = main->get_dp_core_count();
    section["dp_core_count_per_port"] = main->get_dp_core_count() / (main->get_port_count() / 2);
    section["core_type"] = get_cpu_model();

    /* ports */


    section["port_count"] = main->get_port_count();

    section["ports"] = Json::arrayValue;

    for (int i = 0; i < main->get_port_count(); i++) {
        string driver;
        string pci_addr;
        string description;
        supp_speeds_t supp_speeds;
        int numa;

        TrexStatelessPort *port = main->get_port_by_id(i);

        port->get_properties(driver);

        port->get_pci_info(pci_addr, numa);
        main->get_platform_api()->getPortAttrObj(i)->get_description(description);
        main->get_platform_api()->getPortAttrObj(i)->get_supported_speeds(supp_speeds);

        section["ports"][i]["index"]   = i;

        section["ports"][i]["driver"]       = driver;
        section["ports"][i]["description"]  = description;

        section["ports"][i]["pci_addr"]     = pci_addr;
        section["ports"][i]["numa"]         = numa;

        uint16_t caps = port->get_rx_caps();
        section["ports"][i]["rx"]["caps"]      = Json::arrayValue;
        if (caps & TrexPlatformApi::IF_STAT_IPV4_ID) {
            section["ports"][i]["rx"]["caps"].append("flow_stats");
        }
        if (caps & TrexPlatformApi::IF_STAT_PAYLOAD) {
            section["ports"][i]["rx"]["caps"].append("latency");
        }
        if (caps & TrexPlatformApi::IF_STAT_RX_BYTES_COUNT) {
            section["ports"][i]["rx"]["caps"].append("rx_bytes");
        }
        section["ports"][i]["rx"]["counters"]  = port->get_rx_count_num();
        section["ports"][i]["is_fc_supported"] = get_stateless_obj()->get_platform_api()->getPortAttrObj(i)->is_fc_change_supported();
        section["ports"][i]["is_led_supported"] = get_stateless_obj()->get_platform_api()->getPortAttrObj(i)->is_led_change_supported();
        section["ports"][i]["is_link_supported"] = get_stateless_obj()->get_platform_api()->getPortAttrObj(i)->is_link_change_supported();
        section["ports"][i]["is_virtual"] = get_stateless_obj()->get_platform_api()->getPortAttrObj(i)->is_virtual();
        section["ports"][i]["supp_speeds"] = Json::arrayValue;
        for (int speed_id=0; speed_id<supp_speeds.size(); speed_id++) {
            section["ports"][i]["supp_speeds"].append(supp_speeds[speed_id]);
        }

    }

    return (TREX_RPC_CMD_OK);
}