summaryrefslogtreecommitdiffstats
path: root/src/rpc-server/commands/trex_rpc_cmd_general.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/rpc-server/commands/trex_rpc_cmd_general.cpp')
-rw-r--r--src/rpc-server/commands/trex_rpc_cmd_general.cpp113
1 files changed, 107 insertions, 6 deletions
diff --git a/src/rpc-server/commands/trex_rpc_cmd_general.cpp b/src/rpc-server/commands/trex_rpc_cmd_general.cpp
index 342ec594..109cc1a4 100644
--- a/src/rpc-server/commands/trex_rpc_cmd_general.cpp
+++ b/src/rpc-server/commands/trex_rpc_cmd_general.cpp
@@ -295,6 +295,8 @@ TrexRpcCmdGetSysInfo::_run(const Json::Value &params, Json::Value &result) {
string src_macaddr;
string dst_macaddr;
string pci_addr;
+ string description;
+ supp_speeds_t supp_speeds;
int numa;
TrexStatelessPort *port = main->get_port_by_id(i);
@@ -302,10 +304,13 @@ TrexRpcCmdGetSysInfo::_run(const Json::Value &params, Json::Value &result) {
port->get_macaddr(hw_macaddr, src_macaddr, dst_macaddr);
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]["hw_macaddr"] = hw_macaddr;
section["ports"][i]["src_macaddr"] = src_macaddr;
section["ports"][i]["dst_macaddr"] = dst_macaddr;
@@ -326,6 +331,14 @@ TrexRpcCmdGetSysInfo::_run(const Json::Value &params, Json::Value &result) {
}
section["ports"][i]["rx"]["counters"] = port->get_rx_count_num();
section["ports"][i]["speed"] = (uint16_t) speed / 1000;
+ 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]);
+ }
}
@@ -346,19 +359,45 @@ trex_rpc_cmd_rc_e
TrexRpcCmdSetPortAttr::_run(const Json::Value &params, Json::Value &result) {
uint8_t port_id = parse_port(params, result);
- TrexStatelessPort *port = get_stateless_obj()->get_port_by_id(port_id);
const Json::Value &attr = parse_object(params, "attr", result);
-
+ int ret = 0;
+ bool changed = false;
/* iterate over all attributes in the dict */
for (const std::string &name : attr.getMemberNames()) {
-
- /* handle promiscuous */
if (name == "promiscuous") {
bool enabled = parse_bool(attr[name], "enabled", result);
- port->set_promiscuous(enabled);
+ ret = get_stateless_obj()->get_platform_api()->getPortAttrObj(port_id)->set_promiscuous(enabled);
+ }
+ else if (name == "link_status") {
+ bool up = parse_bool(attr[name], "up", result);
+ ret = get_stateless_obj()->get_platform_api()->getPortAttrObj(port_id)->set_link_up(up);
+ }
+ else if (name == "led_status") {
+ bool on = parse_bool(attr[name], "on", result);
+ ret = get_stateless_obj()->get_platform_api()->getPortAttrObj(port_id)->set_led(on);
+ } else if (name == "flow_ctrl_mode") {
+ int mode = parse_int(attr[name], "mode", result);
+ ret = get_stateless_obj()->get_platform_api()->getPortAttrObj(port_id)->set_flow_ctrl(mode);
+ } else {
+ generate_execute_err(result, "Not recognized attribute: " + name);
+ break;
+ }
+ if (ret != 0){
+ if ( ret == -ENOTSUP ) {
+ generate_execute_err(result, "Error applying " + name + ": operation is not supported for this NIC.");
+ }
+ else if (ret) {
+ generate_execute_err(result, "Error applying " + name + " attribute, return value: " + to_string(ret));
+ }
+ break;
+ } else {
+ changed = true;
}
}
+ if (changed) {
+ get_stateless_obj()->get_platform_api()->publish_async_port_attr_changed(port_id);
+ }
result["result"] = Json::objectValue;
return (TREX_RPC_CMD_OK);
@@ -437,6 +476,60 @@ TrexRpcCmdRelease::_run(const Json::Value &params, Json::Value &result) {
}
/**
+ * get port extended stats names (keys of dict)
+ *
+ */
+trex_rpc_cmd_rc_e
+TrexRpcCmdGetPortXStatsNames::_run(const Json::Value &params, Json::Value &result) {
+
+ uint8_t port_id = parse_port(params, result);
+ xstats_names_t xstats_names;
+
+ int ret = get_stateless_obj()->get_platform_api()->get_xstats_names(port_id, xstats_names);
+ if (ret < 0) {
+ if ( ret == -ENOTSUP ) {
+ generate_execute_err(result, "Operation not supported");
+ }
+ else if (ret) {
+ generate_execute_err(result, "Operation failed, error code: " + to_string(ret));
+ }
+ } else {
+ for (int i=0; i<xstats_names.size(); i++) {
+ result["result"]["xstats_names"].append(xstats_names[i]);
+ }
+ }
+
+ return (TREX_RPC_CMD_OK);
+}
+
+/**
+ * get port extended stats (values of dict)
+ *
+ */
+trex_rpc_cmd_rc_e
+TrexRpcCmdGetPortXStatsValues::_run(const Json::Value &params, Json::Value &result) {
+
+ uint8_t port_id = parse_port(params, result);
+ xstats_values_t xstats_values;
+
+ int ret = get_stateless_obj()->get_platform_api()->get_xstats_values(port_id, xstats_values);
+ if (ret < 0) {
+ if ( ret == -ENOTSUP ) {
+ generate_execute_err(result, "Operation not supported");
+ }
+ else if (ret) {
+ generate_execute_err(result, "Operation failed, error code: " + to_string(ret));
+ }
+ } else {
+ for (int i=0; i<xstats_values.size(); i++) {
+ result["result"]["xstats_values"].append((Json::Value::UInt64) xstats_values[i]);
+ }
+ }
+
+ return (TREX_RPC_CMD_OK);
+}
+
+/**
* get port stats
*
*/
@@ -475,9 +568,17 @@ TrexRpcCmdGetPortStatus::_run(const Json::Value &params, Json::Value &result) {
result["result"]["owner"] = (port->get_owner().is_free() ? "" : port->get_owner().get_name());
result["result"]["state"] = port->get_state_as_string();
result["result"]["max_stream_id"] = port->get_max_stream_id();
+ result["result"]["speed"] = get_stateless_obj()->get_platform_api()->getPortAttrObj(port_id)->get_link_speed();
/* attributes */
- result["result"]["attr"]["promiscuous"]["enabled"] = port->get_promiscuous();
+ result["result"]["attr"]["promiscuous"]["enabled"] = get_stateless_obj()->get_platform_api()->getPortAttrObj(port_id)->get_promiscuous();
+ result["result"]["attr"]["link"]["up"] = get_stateless_obj()->get_platform_api()->getPortAttrObj(port_id)->is_link_up();
+ int mode;
+ int ret = get_stateless_obj()->get_platform_api()->getPortAttrObj(port_id)->get_flow_ctrl(mode);
+ if (ret != 0) {
+ mode = -1;
+ }
+ result["result"]["attr"]["fc"]["mode"] = mode;
return (TREX_RPC_CMD_OK);
}