* [PATCH 00/10] support telemetry query ethdev info
@ 2023-05-30 9:05 Jie Hai
2023-05-30 9:05 ` [PATCH 01/10] ethdev: support telemetry query MAC addresses Jie Hai
` (12 more replies)
0 siblings, 13 replies; 36+ messages in thread
From: Jie Hai @ 2023-05-30 9:05 UTC (permalink / raw)
Cc: dev, liudongdong3
This patchset supports querying information about ethdev.
The information includes MAC addresses, RxTx offload, flow ctrl,
Rx|Tx queue, firmware version, DCB, RSS, FEC, VLAN, etc.
Dengdui Huang (1):
ethdev: support telemetry query MAC addresses
Jie Hai (9):
ethdev: support RxTx offload display
ethdev: support telemetry query flow ctrl info
ethdev: support telemetry query Rx queue info
ethdev: support telemetry query Tx queue info
ethdev: add firmware version in telemetry info command
ethdev: support telemetry query DCB info
ethdev: support telemetry query RSS info
ethdev: support telemetry query FEC info
ethdev: support telemetry query VLAN info
lib/ethdev/rte_ethdev.c | 775 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 765 insertions(+), 10 deletions(-)
--
2.33.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH 01/10] ethdev: support telemetry query MAC addresses
2023-05-30 9:05 [PATCH 00/10] support telemetry query ethdev info Jie Hai
@ 2023-05-30 9:05 ` Jie Hai
2023-06-01 14:39 ` Ferruh Yigit
2023-05-30 9:05 ` [PATCH 02/10] ethdev: support RxTx offload display Jie Hai
` (11 subsequent siblings)
12 siblings, 1 reply; 36+ messages in thread
From: Jie Hai @ 2023-05-30 9:05 UTC (permalink / raw)
To: Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko; +Cc: dev, liudongdong3
From: Dengdui Huang <huangdengdui@huawei.com>
This patch support telemetry query MAC addresses for a specific port.
The command is like:
--> /ethdev/macs,0
{
"/ethdev/macs": [
"00:18:2D:00:00:79",
"00:18:2D:00:00:78",
"00:18:2D:00:00:77"
]
}
Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
---
lib/ethdev/rte_ethdev.c | 44 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index d46e74504e64..65e0101fc0eb 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -7032,6 +7032,48 @@ int rte_eth_dev_map_aggr_tx_affinity(uint16_t port_id, uint16_t tx_queue_id,
return ret;
}
+static int
+eth_dev_handle_port_macs(const char *cmd __rte_unused,
+ const char *params,
+ struct rte_tel_data *d)
+{
+ char mac_addr[RTE_ETHER_ADDR_FMT_SIZE];
+ struct rte_eth_dev_info dev_info;
+ struct rte_eth_dev *eth_dev;
+ unsigned long port_id;
+ char *end_param;
+ uint32_t i;
+ int ret;
+
+ if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+ return -EINVAL;
+
+ port_id = strtoul(params, &end_param, 0);
+ if (*end_param != '\0')
+ RTE_ETHDEV_LOG(NOTICE,
+ "Extra parameters passed to ethdev telemetry command, ignoring");
+
+ if (port_id >= UINT16_MAX)
+ return -EINVAL;
+
+ ret = rte_eth_dev_info_get(port_id, &dev_info);
+ if (ret != 0)
+ return ret;
+
+ eth_dev = &rte_eth_devices[port_id];
+ rte_tel_data_start_array(d, RTE_TEL_STRING_VAL);
+ for (i = 0; i < dev_info.max_mac_addrs; i++) {
+ if (rte_is_zero_ether_addr(ð_dev->data->mac_addrs[i]))
+ continue;
+
+ rte_ether_format_addr(mac_addr, sizeof(mac_addr),
+ ð_dev->data->mac_addrs[i]);
+ rte_tel_data_add_array_string(d, mac_addr);
+ }
+
+ return 0;
+}
+
RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO);
RTE_INIT(ethdev_init_telemetry)
@@ -7053,4 +7095,6 @@ RTE_INIT(ethdev_init_telemetry)
"Returns the device info for a port. Parameters: int port_id");
rte_telemetry_register_cmd("/ethdev/module_eeprom", eth_dev_handle_port_module_eeprom,
"Returns module EEPROM info with SFF specs. Parameters: int port_id");
+ rte_telemetry_register_cmd("/ethdev/macs", eth_dev_handle_port_macs,
+ "Returns the MAC addresses for a port. Parameters: int port_id");
}
--
2.33.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH 02/10] ethdev: support RxTx offload display
2023-05-30 9:05 [PATCH 00/10] support telemetry query ethdev info Jie Hai
2023-05-30 9:05 ` [PATCH 01/10] ethdev: support telemetry query MAC addresses Jie Hai
@ 2023-05-30 9:05 ` Jie Hai
2023-05-30 9:05 ` [PATCH 03/10] ethdev: support telemetry query flow ctrl info Jie Hai
` (10 subsequent siblings)
12 siblings, 0 replies; 36+ messages in thread
From: Jie Hai @ 2023-05-30 9:05 UTC (permalink / raw)
To: Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko; +Cc: dev, liudongdong3
Currently, Rx/Tx offloads are displayed in numeric format,
which is not easy to understand. This patch fixes it.
Signed-off-by: Jie Hai <haijie1@huawei.com>
---
lib/ethdev/rte_ethdev.c | 67 +++++++++++++++++++++++++++++++++++------
1 file changed, 57 insertions(+), 10 deletions(-)
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index 65e0101fc0eb..3207b3177256 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -6607,16 +6607,44 @@ eth_dev_handle_port_link_status(const char *cmd __rte_unused,
return 0;
}
+static void
+eth_dev_parse_rx_offloads(uint64_t offload, struct rte_tel_data *d)
+{
+ uint32_t i;
+
+ rte_tel_data_start_array(d, RTE_TEL_STRING_VAL);
+ for (i = 0; i < RTE_DIM(eth_dev_rx_offload_names); i++) {
+ if ((offload & eth_dev_rx_offload_names[i].offload) != 0)
+ rte_tel_data_add_array_string(d,
+ eth_dev_rx_offload_names[i].name);
+ }
+}
+
+static void
+eth_dev_parse_tx_offloads(uint64_t offload, struct rte_tel_data *d)
+{
+ uint32_t i;
+
+ rte_tel_data_start_array(d, RTE_TEL_STRING_VAL);
+ for (i = 0; i < RTE_DIM(eth_dev_tx_offload_names); i++) {
+ if ((offload & eth_dev_tx_offload_names[i].offload) != 0)
+ rte_tel_data_add_array_string(d,
+ eth_dev_tx_offload_names[i].name);
+ }
+}
+
static int
eth_dev_handle_port_info(const char *cmd __rte_unused,
const char *params,
struct rte_tel_data *d)
{
+ struct rte_tel_data *rx_offload, *tx_offload;
struct rte_tel_data *rxq_state, *txq_state;
char mac_addr[RTE_ETHER_ADDR_FMT_SIZE];
struct rte_eth_dev *eth_dev;
char *end_param;
- int port_id, i;
+ int port_id;
+ uint32_t i;
if (params == NULL || strlen(params) == 0 || !isdigit(*params))
return -1;
@@ -6632,14 +6660,20 @@ eth_dev_handle_port_info(const char *cmd __rte_unused,
eth_dev = &rte_eth_devices[port_id];
rxq_state = rte_tel_data_alloc();
- if (!rxq_state)
+ if (rxq_state == NULL)
return -ENOMEM;
txq_state = rte_tel_data_alloc();
- if (!txq_state) {
- rte_tel_data_free(rxq_state);
- return -ENOMEM;
- }
+ if (txq_state == NULL)
+ goto free_rxq_state;
+
+ rx_offload = rte_tel_data_alloc();
+ if (rx_offload == NULL)
+ goto free_txq_state;
+
+ tx_offload = rte_tel_data_alloc();
+ if (tx_offload == NULL)
+ goto free_rx_offload;
rte_tel_data_start_dict(d);
rte_tel_data_add_dict_string(d, "name", eth_dev->data->name);
@@ -6681,14 +6715,27 @@ eth_dev_handle_port_info(const char *cmd __rte_unused,
rte_tel_data_add_dict_int(d, "numa_node", eth_dev->data->numa_node);
rte_tel_data_add_dict_uint_hex(d, "dev_flags",
eth_dev->data->dev_flags, 0);
- rte_tel_data_add_dict_uint_hex(d, "rx_offloads",
- eth_dev->data->dev_conf.rxmode.offloads, 0);
- rte_tel_data_add_dict_uint_hex(d, "tx_offloads",
- eth_dev->data->dev_conf.txmode.offloads, 0);
+
+ eth_dev_parse_rx_offloads(eth_dev->data->dev_conf.rxmode.offloads,
+ rx_offload);
+ rte_tel_data_add_dict_container(d, "rx_offloads", rx_offload, 0);
+ eth_dev_parse_tx_offloads(eth_dev->data->dev_conf.txmode.offloads,
+ tx_offload);
+ rte_tel_data_add_dict_container(d, "tx_offloads", tx_offload, 0);
+
rte_tel_data_add_dict_uint_hex(d, "ethdev_rss_hf",
eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf, 0);
return 0;
+
+free_rx_offload:
+ rte_tel_data_free(rx_offload);
+free_txq_state:
+ rte_tel_data_free(txq_state);
+free_rxq_state:
+ rte_tel_data_free(rxq_state);
+
+ return -ENOMEM;
}
int
--
2.33.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH 03/10] ethdev: support telemetry query flow ctrl info
2023-05-30 9:05 [PATCH 00/10] support telemetry query ethdev info Jie Hai
2023-05-30 9:05 ` [PATCH 01/10] ethdev: support telemetry query MAC addresses Jie Hai
2023-05-30 9:05 ` [PATCH 02/10] ethdev: support RxTx offload display Jie Hai
@ 2023-05-30 9:05 ` Jie Hai
2023-05-30 9:05 ` [PATCH 04/10] ethdev: support telemetry query Rx queue info Jie Hai
` (9 subsequent siblings)
12 siblings, 0 replies; 36+ messages in thread
From: Jie Hai @ 2023-05-30 9:05 UTC (permalink / raw)
To: Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko; +Cc: dev, liudongdong3
This patch supports telemetry querying flow control info.
The command is like:
--> /ethdev/flow_ctrl,0
{
"/ethdev/flow_ctrl": {
"high_waterline": "0x0",
"low_waterline": "0x0",
"pause_time": "0xffff",
"send_xon": "off",
"mac_ctrl_frame_fwd": "off",
"rx_pause": "off",
"tx_pause": "off",
"autoneg": "off"
}
}
Signed-off-by: Jie Hai <haijie1@huawei.com>
---
lib/ethdev/rte_ethdev.c | 51 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index 3207b3177256..5cdb310ca979 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -7121,6 +7121,55 @@ eth_dev_handle_port_macs(const char *cmd __rte_unused,
return 0;
}
+static int
+eth_dev_handle_port_flow_ctrl(const char *cmd __rte_unused,
+ const char *params,
+ struct rte_tel_data *d)
+{
+ struct rte_eth_fc_conf fc_conf;
+ unsigned long port_id;
+ char *end_param;
+ bool rx_fc_en;
+ bool tx_fc_en;
+ int ret;
+
+ if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+ return -EINVAL;
+
+ port_id = strtoul(params, &end_param, 0);
+ if (*end_param != '\0')
+ RTE_ETHDEV_LOG(NOTICE,
+ "Extra parameters passed to ethdev telemetry command, ignoring\n");
+
+ if (port_id >= UINT16_MAX || !rte_eth_dev_is_valid_port(port_id))
+ return -EINVAL;
+
+ ret = rte_eth_dev_flow_ctrl_get(port_id, &fc_conf);
+ if (ret != 0) {
+ RTE_ETHDEV_LOG(ERR,
+ "Failed to get flow ctrl info, ret = %d\n", ret);
+ return ret;
+ }
+
+ rx_fc_en = fc_conf.mode == RTE_ETH_FC_RX_PAUSE ||
+ fc_conf.mode == RTE_ETH_FC_FULL;
+ tx_fc_en = fc_conf.mode == RTE_ETH_FC_TX_PAUSE ||
+ fc_conf.mode == RTE_ETH_FC_FULL;
+
+ rte_tel_data_start_dict(d);
+ rte_tel_data_add_dict_uint_hex(d, "high_waterline", fc_conf.high_water, 0);
+ rte_tel_data_add_dict_uint_hex(d, "low_waterline", fc_conf.low_water, 0);
+ rte_tel_data_add_dict_uint_hex(d, "pause_time", fc_conf.pause_time, 0);
+ rte_tel_data_add_dict_string(d, "send_xon", fc_conf.send_xon ? "on" : "off");
+ rte_tel_data_add_dict_string(d, "mac_ctrl_frame_fwd",
+ fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
+ rte_tel_data_add_dict_string(d, "rx_pause", rx_fc_en ? "on" : "off");
+ rte_tel_data_add_dict_string(d, "tx_pause", tx_fc_en ? "on" : "off");
+ rte_tel_data_add_dict_string(d, "autoneg", fc_conf.autoneg ? "on" : "off");
+
+ return 0;
+}
+
RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO);
RTE_INIT(ethdev_init_telemetry)
@@ -7144,4 +7193,6 @@ RTE_INIT(ethdev_init_telemetry)
"Returns module EEPROM info with SFF specs. Parameters: int port_id");
rte_telemetry_register_cmd("/ethdev/macs", eth_dev_handle_port_macs,
"Returns the MAC addresses for a port. Parameters: int port_id");
+ rte_telemetry_register_cmd("/ethdev/flow_ctrl", eth_dev_handle_port_flow_ctrl,
+ "Returns flow ctrl info for a port. Parameters: unsigned port_id");
}
--
2.33.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH 04/10] ethdev: support telemetry query Rx queue info
2023-05-30 9:05 [PATCH 00/10] support telemetry query ethdev info Jie Hai
` (2 preceding siblings ...)
2023-05-30 9:05 ` [PATCH 03/10] ethdev: support telemetry query flow ctrl info Jie Hai
@ 2023-05-30 9:05 ` Jie Hai
2023-05-30 9:05 ` [PATCH 05/10] ethdev: support telemetry query Tx " Jie Hai
` (8 subsequent siblings)
12 siblings, 0 replies; 36+ messages in thread
From: Jie Hai @ 2023-05-30 9:05 UTC (permalink / raw)
To: Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko; +Cc: dev, liudongdong3
This patch support querying information of Rx queues.
The command is like:
--> /ethdev/rx_queue,0,0
{
"/ethdev/rx_queue": {
"mempool_name": "mb_pool_0",
"socket_id": 0,
"host_threshold": 0,
"prefetch_threshold": 0,
"writeback_threshold": 0,
"free_threshold": 32,
"rx_drop_en": "on",
"deferred_start": "off",
"rx_nseg": 0,
"share_group": 0,
"share_qid": 0,
"offloads": [
"RSS_HASH"
],
"rx_nmempool": 0,
"scattered_rx": "off",
"queue_state": 1,
"nb_desc": 1024,
"rx_buf_size": 2048,
"avail_thresh": 0,
"burst_flags": 0,
"burst_mode": "Vector Neon"
}
}
Signed-off-by: Jie Hai <haijie1@huawei.com>
---
lib/ethdev/rte_ethdev.c | 127 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 127 insertions(+)
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index 5cdb310ca979..35c13df1c110 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -7170,6 +7170,131 @@ eth_dev_handle_port_flow_ctrl(const char *cmd __rte_unused,
return 0;
}
+static int
+parse_queue_params(const char *params, bool is_rx,
+ unsigned long *port_id, unsigned long *queue_id)
+{
+ struct rte_eth_dev *dev;
+ const char *qid_param;
+ uint16_t nb_queues;
+ char *end_param;
+
+ if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+ return -EINVAL;
+
+ *port_id = strtoul(params, &end_param, 0);
+ if (*port_id >= UINT16_MAX || !rte_eth_dev_is_valid_port(*port_id))
+ return -EINVAL;
+
+ dev = &rte_eth_devices[*port_id];
+ nb_queues = is_rx ? dev->data->nb_rx_queues : dev->data->nb_tx_queues;
+ if (nb_queues == 1 && *end_param == '\0')
+ *queue_id = 0;
+ else {
+ qid_param = strtok(end_param, ",");
+ if (!qid_param || strlen(qid_param) == 0 || !isdigit(*qid_param))
+ return -EINVAL;
+
+ *queue_id = strtoul(qid_param, &end_param, 0);
+ }
+ if (*end_param != '\0')
+ RTE_ETHDEV_LOG(NOTICE,
+ "Extra parameters passed to ethdev telemetry command, ignoring\n");
+
+ if (*queue_id >= UINT16_MAX)
+ return -EINVAL;
+
+ return 0;
+}
+
+static int
+eth_dev_add_burst_mode(unsigned long port_id, unsigned long queue_id,
+ bool is_rx, struct rte_tel_data *d)
+{
+ struct rte_eth_burst_mode mode;
+ int ret;
+
+ if (is_rx)
+ ret = rte_eth_rx_burst_mode_get(port_id, queue_id, &mode);
+ else
+ ret = rte_eth_tx_burst_mode_get(port_id, queue_id, &mode);
+
+ if (ret == -ENOTSUP)
+ return 0;
+
+ if (ret != 0) {
+ RTE_ETHDEV_LOG(ERR,
+ "Failed to get burst mode for port %lu\n", port_id);
+ return ret;
+ }
+
+ rte_tel_data_add_dict_uint(d, "burst_flags", mode.flags);
+ rte_tel_data_add_dict_string(d, "burst_mode", mode.info);
+ return 0;
+}
+
+static int
+eth_dev_handle_port_rxq(const char *cmd __rte_unused,
+ const char *params,
+ struct rte_tel_data *d)
+{
+ struct rte_eth_thresh *rx_thresh;
+ unsigned long port_id, queue_id;
+ struct rte_eth_rxconf *rxconf;
+ struct rte_eth_rxq_info qinfo;
+ struct rte_tel_data *offload;
+ int ret;
+
+ ret = parse_queue_params(params, true, &port_id, &queue_id);
+ if (ret != 0)
+ return ret;
+
+ ret = rte_eth_rx_queue_info_get(port_id, queue_id, &qinfo);
+ if (ret != 0)
+ return ret;
+
+ rte_tel_data_start_dict(d);
+ rte_tel_data_add_dict_string(d, "mempool_name", qinfo.mp->name);
+ rte_tel_data_add_dict_uint(d, "socket_id", qinfo.mp->socket_id);
+
+ rx_thresh = &qinfo.conf.rx_thresh;
+ rte_tel_data_add_dict_uint(d, "host_threshold", rx_thresh->hthresh);
+ rte_tel_data_add_dict_uint(d, "prefetch_threshold", rx_thresh->pthresh);
+ rte_tel_data_add_dict_uint(d, "writeback_threshold", rx_thresh->wthresh);
+
+ rxconf = &qinfo.conf;
+ rte_tel_data_add_dict_uint(d, "free_threshold", rxconf->rx_free_thresh);
+ rte_tel_data_add_dict_string(d, "rx_drop_en",
+ rxconf->rx_drop_en == 0 ? "off" : "on");
+ rte_tel_data_add_dict_string(d, "deferred_start",
+ rxconf->rx_deferred_start == 0 ? "off" : "on");
+ rte_tel_data_add_dict_uint(d, "rx_nseg", rxconf->rx_nseg);
+ rte_tel_data_add_dict_uint(d, "share_group", rxconf->share_group);
+ rte_tel_data_add_dict_uint(d, "share_qid", rxconf->share_qid);
+
+ offload = rte_tel_data_alloc();
+ if (offload == NULL)
+ return -ENOMEM;
+
+ eth_dev_parse_rx_offloads(rxconf->offloads, offload);
+ rte_tel_data_add_dict_container(d, "offloads", offload, 0);
+
+ rte_tel_data_add_dict_uint(d, "rx_nmempool", rxconf->rx_nmempool);
+
+ rte_tel_data_add_dict_string(d, "scattered_rx",
+ qinfo.scattered_rx == 0 ? "off" : "on");
+ rte_tel_data_add_dict_uint(d, "queue_state", qinfo.queue_state);
+ rte_tel_data_add_dict_uint(d, "nb_desc", qinfo.nb_desc);
+ rte_tel_data_add_dict_uint(d, "rx_buf_size", qinfo.rx_buf_size);
+ rte_tel_data_add_dict_uint(d, "avail_thresh", qinfo.avail_thresh);
+
+ ret = eth_dev_add_burst_mode(port_id, queue_id, true, d);
+ if (ret != 0)
+ rte_tel_data_free(offload);
+
+ return ret;
+}
+
RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO);
RTE_INIT(ethdev_init_telemetry)
@@ -7195,4 +7320,6 @@ RTE_INIT(ethdev_init_telemetry)
"Returns the MAC addresses for a port. Parameters: int port_id");
rte_telemetry_register_cmd("/ethdev/flow_ctrl", eth_dev_handle_port_flow_ctrl,
"Returns flow ctrl info for a port. Parameters: unsigned port_id");
+ rte_telemetry_register_cmd("/ethdev/rx_queue", eth_dev_handle_port_rxq,
+ "Returns Rx queue info for a port. Parameters: unsigned port_id, unsigned queue_id (Optional if only one queue)");
}
--
2.33.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH 05/10] ethdev: support telemetry query Tx queue info
2023-05-30 9:05 [PATCH 00/10] support telemetry query ethdev info Jie Hai
` (3 preceding siblings ...)
2023-05-30 9:05 ` [PATCH 04/10] ethdev: support telemetry query Rx queue info Jie Hai
@ 2023-05-30 9:05 ` Jie Hai
2023-05-30 9:05 ` [PATCH 06/10] ethdev: add firmware version in telemetry info command Jie Hai
` (7 subsequent siblings)
12 siblings, 0 replies; 36+ messages in thread
From: Jie Hai @ 2023-05-30 9:05 UTC (permalink / raw)
To: Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko; +Cc: dev, liudongdong3
This patch support querying information of Tx queues.
The command is like:
--> /ethdev/tx_queue,0,0
{
"/ethdev/tx_queue": {
"host_threshold": 0,
"prefetch_threshold": 0,
"writeback_threshold": 0,
"rs_threshold": 32,
"free_threshold": 928,
"deferred_start": "off",
"offloads": [
"MBUF_FAST_FREE"
],
"queue_state": 1,
"nb_desc": 1024,
"burst_flags": 0,
"burst_mode": "Vector Neon"
}
}
Signed-off-by: Jie Hai <haijie1@huawei.com>
---
lib/ethdev/rte_ethdev.c | 50 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index 35c13df1c110..315334321cb3 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -7295,6 +7295,54 @@ eth_dev_handle_port_rxq(const char *cmd __rte_unused,
return ret;
}
+static int
+eth_dev_handle_port_txq(const char *cmd __rte_unused,
+ const char *params,
+ struct rte_tel_data *d)
+{
+ struct rte_eth_thresh *tx_thresh;
+ unsigned long port_id, queue_id;
+ struct rte_eth_txconf *txconf;
+ struct rte_eth_txq_info qinfo;
+ struct rte_tel_data *offload;
+ int ret;
+
+ ret = parse_queue_params(params, false, &port_id, &queue_id);
+ if (ret != 0)
+ return ret;
+
+ ret = rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo);
+ if (ret != 0)
+ return ret;
+
+ rte_tel_data_start_dict(d);
+ tx_thresh = &qinfo.conf.tx_thresh;
+ txconf = &qinfo.conf;
+ rte_tel_data_add_dict_uint(d, "host_threshold", tx_thresh->hthresh);
+ rte_tel_data_add_dict_uint(d, "prefetch_threshold", tx_thresh->pthresh);
+ rte_tel_data_add_dict_uint(d, "writeback_threshold", tx_thresh->wthresh);
+ rte_tel_data_add_dict_uint(d, "rs_threshold", txconf->tx_rs_thresh);
+ rte_tel_data_add_dict_uint(d, "free_threshold", txconf->tx_free_thresh);
+ rte_tel_data_add_dict_string(d, "deferred_start",
+ txconf->tx_deferred_start == 0 ? "off" : "on");
+
+ offload = rte_tel_data_alloc();
+ if (offload == NULL)
+ return -ENOMEM;
+
+ eth_dev_parse_tx_offloads(txconf->offloads, offload);
+ rte_tel_data_add_dict_container(d, "offloads", offload, 0);
+
+ rte_tel_data_add_dict_uint(d, "queue_state", qinfo.queue_state);
+ rte_tel_data_add_dict_uint(d, "nb_desc", qinfo.nb_desc);
+
+ ret = eth_dev_add_burst_mode(port_id, queue_id, false, d);
+ if (ret != 0)
+ rte_tel_data_free(offload);
+
+ return 0;
+}
+
RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO);
RTE_INIT(ethdev_init_telemetry)
@@ -7322,4 +7370,6 @@ RTE_INIT(ethdev_init_telemetry)
"Returns flow ctrl info for a port. Parameters: unsigned port_id");
rte_telemetry_register_cmd("/ethdev/rx_queue", eth_dev_handle_port_rxq,
"Returns Rx queue info for a port. Parameters: unsigned port_id, unsigned queue_id (Optional if only one queue)");
+ rte_telemetry_register_cmd("/ethdev/tx_queue", eth_dev_handle_port_txq,
+ "Returns Tx queue info for a port. Parameters: unsigned port_id, unsigned queue_id (Optional if only one queue)");
}
--
2.33.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH 06/10] ethdev: add firmware version in telemetry info command
2023-05-30 9:05 [PATCH 00/10] support telemetry query ethdev info Jie Hai
` (4 preceding siblings ...)
2023-05-30 9:05 ` [PATCH 05/10] ethdev: support telemetry query Tx " Jie Hai
@ 2023-05-30 9:05 ` Jie Hai
2023-05-30 9:05 ` [PATCH 07/10] ethdev: support telemetry query DCB info Jie Hai
` (6 subsequent siblings)
12 siblings, 0 replies; 36+ messages in thread
From: Jie Hai @ 2023-05-30 9:05 UTC (permalink / raw)
To: Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko; +Cc: dev, liudongdong3
This patch adds firmware version in telemetry info command.
An example is like:
--> /ethdev/info,0
{
"/ethdev/info": {
"name": "0000:bd:00.0",
"fw_version": "1.20.0.17",
....
}
}
Signed-off-by: Jie Hai <haijie1@huawei.com>
---
lib/ethdev/rte_ethdev.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index 315334321cb3..d906cc66d2f9 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -6640,6 +6640,7 @@ eth_dev_handle_port_info(const char *cmd __rte_unused,
{
struct rte_tel_data *rx_offload, *tx_offload;
struct rte_tel_data *rxq_state, *txq_state;
+ char fw_version[RTE_TEL_MAX_STRING_LEN];
char mac_addr[RTE_ETHER_ADDR_FMT_SIZE];
struct rte_eth_dev *eth_dev;
char *end_param;
@@ -6677,6 +6678,11 @@ eth_dev_handle_port_info(const char *cmd __rte_unused,
rte_tel_data_start_dict(d);
rte_tel_data_add_dict_string(d, "name", eth_dev->data->name);
+
+ if (rte_eth_dev_fw_version_get(port_id, fw_version,
+ RTE_TEL_MAX_STRING_LEN) == 0)
+ rte_tel_data_add_dict_string(d, "fw_version", fw_version);
+
rte_tel_data_add_dict_int(d, "state", eth_dev->state);
rte_tel_data_add_dict_int(d, "nb_rx_queues",
eth_dev->data->nb_rx_queues);
--
2.33.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH 07/10] ethdev: support telemetry query DCB info
2023-05-30 9:05 [PATCH 00/10] support telemetry query ethdev info Jie Hai
` (5 preceding siblings ...)
2023-05-30 9:05 ` [PATCH 06/10] ethdev: add firmware version in telemetry info command Jie Hai
@ 2023-05-30 9:05 ` Jie Hai
2023-05-30 9:05 ` [PATCH 08/10] ethdev: support telemetry query RSS info Jie Hai
` (5 subsequent siblings)
12 siblings, 0 replies; 36+ messages in thread
From: Jie Hai @ 2023-05-30 9:05 UTC (permalink / raw)
To: Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko; +Cc: dev, liudongdong3
This patch supports querying DCB info.
The command is like:
--> /ethdev/dcb,0
{
"/ethdev/dcb": {
"tc_num": 1,
"tc0": {
"priority": 0,
"bw_percent": "100%",
"rxq_base": 0,
"txq_base": 0,
"nb_rxq": 4,
"nb_txq": 4
}
}
}
Signed-off-by: Jie Hai <haijie1@huawei.com>
---
lib/ethdev/rte_ethdev.c | 85 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 85 insertions(+)
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index d906cc66d2f9..dad9c5538149 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -7349,6 +7349,89 @@ eth_dev_handle_port_txq(const char *cmd __rte_unused,
return 0;
}
+static int
+eth_dev_add_dcb_tc(struct rte_eth_dcb_info *dcb_info, struct rte_tel_data *d)
+{
+ struct rte_tel_data *tcds[RTE_ETH_DCB_NUM_TCS] = {NULL};
+ struct rte_eth_dcb_tc_queue_mapping *tcq;
+ char bw_percent[RTE_TEL_MAX_STRING_LEN];
+ char name[RTE_TEL_MAX_STRING_LEN];
+ struct rte_tel_data *tcd;
+ uint32_t i;
+
+ for (i = 0; i < dcb_info->nb_tcs; i++) {
+ tcd = rte_tel_data_alloc();
+ if (tcd == NULL) {
+ while (i-- > 0)
+ rte_tel_data_free(tcds[i]);
+ return -ENOMEM;
+ }
+
+ tcds[i] = tcd;
+ rte_tel_data_start_dict(tcd);
+
+ rte_tel_data_add_dict_uint(tcd, "priority", dcb_info->prio_tc[i]);
+ snprintf(bw_percent, RTE_TEL_MAX_STRING_LEN,
+ "%u%%", dcb_info->tc_bws[i]);
+ rte_tel_data_add_dict_string(tcd, "bw_percent", bw_percent);
+
+ tcq = &dcb_info->tc_queue;
+ rte_tel_data_add_dict_uint(tcd, "rxq_base", tcq->tc_rxq[0][i].base);
+ rte_tel_data_add_dict_uint(tcd, "txq_base", tcq->tc_txq[0][i].base);
+ rte_tel_data_add_dict_uint(tcd, "nb_rxq", tcq->tc_rxq[0][i].nb_queue);
+ rte_tel_data_add_dict_uint(tcd, "nb_txq", tcq->tc_txq[0][i].nb_queue);
+
+ snprintf(name, RTE_TEL_MAX_STRING_LEN, "tc%u", i);
+ rte_tel_data_add_dict_container(d, name, tcd, 0);
+ }
+
+ return 0;
+}
+
+static int
+eth_dev_add_dcb_info(uint16_t port_id, struct rte_tel_data *d)
+{
+ struct rte_eth_dcb_info dcb_info;
+ int ret;
+
+ ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
+ if (ret != 0) {
+ RTE_ETHDEV_LOG(ERR,
+ "Failed to get dcb info, ret = %d\n", ret);
+ return ret;
+ }
+
+ rte_tel_data_start_dict(d);
+ rte_tel_data_add_dict_uint(d, "tc_num", dcb_info.nb_tcs);
+
+ if (dcb_info.nb_tcs > 0)
+ return eth_dev_add_dcb_tc(&dcb_info, d);
+
+ return 0;
+}
+
+static int
+eth_dev_handle_port_dcb(const char *cmd __rte_unused,
+ const char *params,
+ struct rte_tel_data *d)
+{
+ unsigned long port_id;
+ char *end_param;
+
+ if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+ return -EINVAL;
+
+ port_id = strtoul(params, &end_param, 0);
+ if (*end_param != '\0')
+ RTE_ETHDEV_LOG(NOTICE,
+ "Extra parameters passed to ethdev telemetry command, ignoring\n");
+
+ if (port_id >= UINT16_MAX || !rte_eth_dev_is_valid_port(port_id))
+ return -EINVAL;
+
+ return eth_dev_add_dcb_info(port_id, d);
+}
+
RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO);
RTE_INIT(ethdev_init_telemetry)
@@ -7378,4 +7461,6 @@ RTE_INIT(ethdev_init_telemetry)
"Returns Rx queue info for a port. Parameters: unsigned port_id, unsigned queue_id (Optional if only one queue)");
rte_telemetry_register_cmd("/ethdev/tx_queue", eth_dev_handle_port_txq,
"Returns Tx queue info for a port. Parameters: unsigned port_id, unsigned queue_id (Optional if only one queue)");
+ rte_telemetry_register_cmd("/ethdev/dcb", eth_dev_handle_port_dcb,
+ "Returns DCB info for a port. Parameters: unsigned port_id");
}
--
2.33.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH 08/10] ethdev: support telemetry query RSS info
2023-05-30 9:05 [PATCH 00/10] support telemetry query ethdev info Jie Hai
` (6 preceding siblings ...)
2023-05-30 9:05 ` [PATCH 07/10] ethdev: support telemetry query DCB info Jie Hai
@ 2023-05-30 9:05 ` Jie Hai
2023-05-30 9:05 ` [PATCH 09/10] ethdev: support telemetry query FEC info Jie Hai
` (4 subsequent siblings)
12 siblings, 0 replies; 36+ messages in thread
From: Jie Hai @ 2023-05-30 9:05 UTC (permalink / raw)
To: Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko; +Cc: dev, liudongdong3
This patch supports querying RSS info by telemetry command.
The command is like:
--> /ethdev/rss_info,0
{
"/ethdev/rss_info": {
"rss_hf": "0x238c",
"rss_key_len": 40,
"rss_key": "6d5a56da255b0ec24167253d43a38fb0d0ca2b\
cbae7b30b477cb2da38030f20c6a42b73bbeac01fa"
}
}
Signed-off-by: Jie Hai <haijie1@huawei.com>
---
lib/ethdev/rte_ethdev.c | 86 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 86 insertions(+)
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index dad9c5538149..6699b40d5e15 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -7432,6 +7432,90 @@ eth_dev_handle_port_dcb(const char *cmd __rte_unused,
return eth_dev_add_dcb_info(port_id, d);
}
+static int
+eth_dev_add_rss_info(struct rte_eth_rss_conf *rss_conf, struct rte_tel_data *d)
+{
+ const uint32_t key_len = rss_conf->rss_key_len * 2 + 1;
+ char *rss_key;
+ char *key;
+ uint32_t i;
+ int ret;
+
+ key = rte_malloc(NULL, key_len, 0);
+ if (key == NULL)
+ return -ENOMEM;
+
+ rss_key = rte_malloc(NULL, key_len, 0);
+ if (rss_key == NULL) {
+ ret = -ENOMEM;
+ goto free_key;
+ }
+
+ rte_tel_data_start_dict(d);
+ rte_tel_data_add_dict_uint_hex(d, "rss_hf", rss_conf->rss_hf, 0);
+ rte_tel_data_add_dict_uint(d, "rss_key_len", rss_conf->rss_key_len);
+
+ memset(rss_key, 0, key_len);
+ for (i = 0; i < rss_conf->rss_key_len; i++) {
+ ret = snprintf(key, key_len, "%02x", rss_conf->rss_key[i]);
+ if (ret < 0)
+ goto free_rss_key;
+ strlcat(rss_key, key, key_len);
+ }
+ ret = rte_tel_data_add_dict_string(d, "rss_key", rss_key);
+
+free_rss_key:
+ rte_free(rss_key);
+free_key:
+ rte_free(key);
+ return ret;
+}
+
+static int
+eth_dev_handle_port_rss_info(const char *cmd __rte_unused,
+ const char *params,
+ struct rte_tel_data *d)
+{
+ struct rte_eth_dev_info dev_info;
+ struct rte_eth_rss_conf rss_conf;
+ unsigned long port_id;
+ char *end_param;
+ int ret;
+
+ if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+ return -EINVAL;
+
+ port_id = strtoul(params, &end_param, 0);
+ if (*end_param != '\0')
+ RTE_ETHDEV_LOG(NOTICE,
+ "Extra parameters passed to ethdev telemetry command, ignoring\n");
+
+ if (port_id >= UINT16_MAX || !rte_eth_dev_is_valid_port(port_id))
+ return -EINVAL;
+
+ ret = rte_eth_dev_info_get(port_id, &dev_info);
+ if (ret != 0) {
+ RTE_ETHDEV_LOG(ERR,
+ "Failed to get device info, ret = %d\n", ret);
+ return ret;
+ }
+
+ rss_conf.rss_key_len = dev_info.hash_key_size;
+ rss_conf.rss_key = rte_malloc(NULL, dev_info.hash_key_size, 0);
+ if (rss_conf.rss_key == NULL)
+ return -ENOMEM;
+
+ ret = rte_eth_dev_rss_hash_conf_get(port_id, &rss_conf);
+ if (ret != 0) {
+ rte_free(rss_conf.rss_key);
+ return ret;
+ }
+
+ ret = eth_dev_add_rss_info(&rss_conf, d);
+ rte_free(rss_conf.rss_key);
+ return ret;
+}
+
RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO);
RTE_INIT(ethdev_init_telemetry)
@@ -7463,4 +7547,6 @@ RTE_INIT(ethdev_init_telemetry)
"Returns Tx queue info for a port. Parameters: unsigned port_id, unsigned queue_id (Optional if only one queue)");
rte_telemetry_register_cmd("/ethdev/dcb", eth_dev_handle_port_dcb,
"Returns DCB info for a port. Parameters: unsigned port_id");
+ rte_telemetry_register_cmd("/ethdev/rss_info", eth_dev_handle_port_rss_info,
+ "Returns RSS info for a port. Parameters: unsigned port_id");
}
--
2.33.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH 09/10] ethdev: support telemetry query FEC info
2023-05-30 9:05 [PATCH 00/10] support telemetry query ethdev info Jie Hai
` (7 preceding siblings ...)
2023-05-30 9:05 ` [PATCH 08/10] ethdev: support telemetry query RSS info Jie Hai
@ 2023-05-30 9:05 ` Jie Hai
2023-05-30 9:05 ` [PATCH 10/10] ethdev: support telemetry query VLAN info Jie Hai
` (3 subsequent siblings)
12 siblings, 0 replies; 36+ messages in thread
From: Jie Hai @ 2023-05-30 9:05 UTC (permalink / raw)
To: Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko; +Cc: dev, liudongdong3
This patch supports getting FEC information by telemetry.
The command is like:
--> /ethdev/fec,0
{
"/ethdev/fec": {
"fec_mode": "off",
"fec_capability": {
"10_Gbps": "off auto baser"
}
}
}
Signed-off-by: Jie Hai <haijie1@huawei.com>
---
lib/ethdev/rte_ethdev.c | 145 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 145 insertions(+)
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index 6699b40d5e15..f7a84ae6c35d 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -160,6 +160,16 @@ enum {
STAT_QMAP_RX
};
+static const struct {
+ uint32_t capa;
+ const char *name;
+} rte_eth_fec_capa_name[] = {
+ { RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC), "off" },
+ { RTE_ETH_FEC_MODE_CAPA_MASK(AUTO), "auto" },
+ { RTE_ETH_FEC_MODE_CAPA_MASK(BASER), "baser" },
+ { RTE_ETH_FEC_MODE_CAPA_MASK(RS), "rs" },
+};
+
int
rte_eth_iterator_init(struct rte_dev_iterator *iter, const char *devargs_str)
{
@@ -7516,6 +7526,139 @@ eth_dev_handle_port_rss_info(const char *cmd __rte_unused,
return ret;
}
+static const char *
+eth_dev_fec_capa_to_string(uint32_t fec_capa)
+{
+ uint32_t i;
+
+ for (i = 0; i < RTE_DIM(rte_eth_fec_capa_name); i++) {
+ if ((fec_capa & rte_eth_fec_capa_name[i].capa) != 0)
+ return rte_eth_fec_capa_name[i].name;
+ }
+
+ return "unknown";
+}
+
+static void
+eth_dev_fec_capas_to_string(uint32_t fec_capa, char *fec_name, uint32_t len)
+{
+ bool valid = false;
+ size_t count = 0;
+ uint32_t i;
+
+ for (i = 0; i < RTE_DIM(rte_eth_fec_capa_name); i++) {
+ if ((fec_capa & rte_eth_fec_capa_name[i].capa) != 0) {
+ strlcat(fec_name, rte_eth_fec_capa_name[i].name, len);
+ count = strlcat(fec_name, " ", len);
+ valid = true;
+ }
+ }
+
+ if (!valid)
+ count = snprintf(fec_name, len, "unknown ");
+
+ if (count >= len) {
+ RTE_ETHDEV_LOG(WARNING, "FEC capa names may be truncated\n");
+ count = len;
+ }
+
+ fec_name[count - 1] = '\0';
+}
+
+static int
+eth_dev_get_fec_capability(uint16_t port_id, struct rte_tel_data *d)
+{
+ struct rte_eth_fec_capa *speed_fec_capa;
+ char fec_name[RTE_TEL_MAX_STRING_LEN];
+ char speed[RTE_TEL_MAX_STRING_LEN];
+ uint32_t capa_num;
+ uint32_t i, j;
+ int ret;
+
+ ret = rte_eth_fec_get_capability(port_id, NULL, 0);
+ if (ret <= 0)
+ return ret == 0 ? -EINVAL : ret;
+
+ capa_num = ret;
+ speed_fec_capa = calloc(capa_num, sizeof(struct rte_eth_fec_capa));
+ if (speed_fec_capa == NULL)
+ return -ENOMEM;
+
+ ret = rte_eth_fec_get_capability(port_id, speed_fec_capa, capa_num);
+ if (ret <= 0) {
+ ret = ret == 0 ? -EINVAL : ret;
+ goto out;
+ }
+
+ for (i = 0; i < capa_num; i++) {
+ memset(fec_name, 0, RTE_TEL_MAX_STRING_LEN);
+ eth_dev_fec_capas_to_string(speed_fec_capa[i].capa, fec_name,
+ RTE_TEL_MAX_STRING_LEN);
+
+ memset(speed, 0, RTE_TEL_MAX_STRING_LEN);
+ ret = snprintf(speed, RTE_TEL_MAX_STRING_LEN, "%s",
+ rte_eth_link_speed_to_str(speed_fec_capa[i].speed));
+ if (ret < 0)
+ goto out;
+
+ for (j = 0; j < strlen(speed); j++) {
+ if (speed[j] == ' ')
+ speed[j] = '_';
+ }
+
+ rte_tel_data_add_dict_string(d, speed, fec_name);
+ }
+
+out:
+ free(speed_fec_capa);
+ return ret > 0 ? 0 : ret;
+}
+
+static int
+eth_dev_handle_port_fec(const char *cmd __rte_unused,
+ const char *params,
+ struct rte_tel_data *d)
+{
+ struct rte_tel_data *fec_capas;
+ unsigned long port_id;
+ uint32_t fec_mode;
+ char *end_param;
+ int ret;
+
+ if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+ return -EINVAL;
+
+ port_id = strtoul(params, &end_param, 0);
+ if (*end_param != '\0')
+ RTE_ETHDEV_LOG(NOTICE,
+ "Extra parameters passed to ethdev telemetry command, ignoring\n");
+
+ if (port_id >= UINT16_MAX || !rte_eth_dev_is_valid_port(port_id))
+ return -EINVAL;
+
+ ret = rte_eth_fec_get(port_id, &fec_mode);
+ if (ret != 0)
+ return ret;
+
+ rte_tel_data_start_dict(d);
+ rte_tel_data_add_dict_string(d, "fec_mode",
+ eth_dev_fec_capa_to_string(fec_mode));
+
+ fec_capas = rte_tel_data_alloc();
+ if (fec_capas == NULL)
+ return -ENOMEM;
+
+ rte_tel_data_start_dict(fec_capas);
+ ret = eth_dev_get_fec_capability(port_id, fec_capas);
+ if (ret != 0) {
+ rte_tel_data_free(fec_capas);
+ return ret;
+ }
+
+ rte_tel_data_add_dict_container(d, "fec_capability", fec_capas, 0);
+ return 0;
+}
+
RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO);
RTE_INIT(ethdev_init_telemetry)
@@ -7549,4 +7692,6 @@ RTE_INIT(ethdev_init_telemetry)
"Returns DCB info for a port. Parameters: unsigned port_id");
rte_telemetry_register_cmd("/ethdev/rss_info", eth_dev_handle_port_rss_info,
"Returns RSS info for a port. Parameters: unsigned port_id");
+ rte_telemetry_register_cmd("/ethdev/fec", eth_dev_handle_port_fec,
+ "Returns FEC info for a port. Parameters: unsigned port_id");
}
--
2.33.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH 10/10] ethdev: support telemetry query VLAN info
2023-05-30 9:05 [PATCH 00/10] support telemetry query ethdev info Jie Hai
` (8 preceding siblings ...)
2023-05-30 9:05 ` [PATCH 09/10] ethdev: support telemetry query FEC info Jie Hai
@ 2023-05-30 9:05 ` Jie Hai
2023-06-01 12:05 ` [PATCH 00/10] support telemetry query ethdev info Ferruh Yigit
` (2 subsequent siblings)
12 siblings, 0 replies; 36+ messages in thread
From: Jie Hai @ 2023-05-30 9:05 UTC (permalink / raw)
To: Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko; +Cc: dev, liudongdong3
This patch supports querying VLAN information by telemetry.
The command is like:
--> /ethdev/vlan,0
{
"/ethdev/vlan": {
"pvid": 0,
"hw_vlan_reject_tagged": 0,
"hw_vlan_reject_untagged": 0,
"hw_vlan_insert_pvid": 0,
"VLAN_STRIP": "off",
"VLAN_EXTEND": "off",
"QINQ_STRIP": "off",
"VLAN_FILTER": "on",
"vlan_num": 3,
"vlan_ids": {
"vlan_0_to_63": [
1,
20
],
"vlan_192_to_255": [
200
]
}
}
}
Signed-off-by: Jie Hai <haijie1@huawei.com>
---
lib/ethdev/rte_ethdev.c | 114 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 114 insertions(+)
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index f7a84ae6c35d..ba3484d8e870 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -7659,6 +7659,118 @@ eth_dev_handle_port_fec(const char *cmd __rte_unused,
return 0;
}
+static int
+eth_dev_add_vlan_id(int port_id, struct rte_tel_data *d)
+{
+ struct rte_tel_data *vlan_blks[64] = {NULL};
+ uint16_t vlan_num, vidx, vbit, num_blks;
+ char blk_name[RTE_TEL_MAX_STRING_LEN];
+ struct rte_vlan_filter_conf *vfc;
+ struct rte_tel_data *vlan_blk;
+ struct rte_tel_data *vd;
+ uint64_t bit_width;
+ uint64_t vlan_id;
+
+ vd = rte_tel_data_alloc();
+ if (vd == NULL)
+ return -ENOMEM;
+
+ vfc = &rte_eth_devices[port_id].data->vlan_filter_conf;
+ bit_width = CHAR_BIT * sizeof(uint64_t);
+ vlan_num = 0;
+ num_blks = 0;
+
+ rte_tel_data_start_dict(vd);
+ for (vidx = 0; vidx < RTE_DIM(vfc->ids); vidx++) {
+ if (vfc->ids[vidx] == 0)
+ continue;
+
+ vlan_blk = rte_tel_data_alloc();
+ if (vlan_blk == NULL)
+ goto free_all;
+
+ vlan_blks[num_blks] = vlan_blk;
+ num_blks++;
+ snprintf(blk_name, RTE_TEL_MAX_STRING_LEN, "vlan_%lu_to_%lu",
+ bit_width * vidx, bit_width * (vidx + 1) - 1);
+ rte_tel_data_start_array(vlan_blk, RTE_TEL_UINT_VAL);
+ rte_tel_data_add_dict_container(vd, blk_name, vlan_blk, 0);
+
+ for (vbit = 0; vbit < bit_width; vbit++) {
+ if ((vfc->ids[vidx] & RTE_BIT64(vbit)) == 0)
+ continue;
+
+ vlan_id = bit_width * vidx + vbit;
+ rte_tel_data_add_array_uint(vlan_blk, vlan_id);
+ vlan_num++;
+ }
+ }
+
+ rte_tel_data_add_dict_uint(d, "vlan_num", vlan_num);
+ rte_tel_data_add_dict_container(d, "vlan_ids", vd, 0);
+
+ return 0;
+
+free_all:
+ while (num_blks-- > 0)
+ rte_tel_data_free(vlan_blks[num_blks]);
+
+ rte_tel_data_free(vd);
+ return -ENOMEM;
+}
+
+static int
+eth_dev_handle_port_vlan(const char *cmd __rte_unused,
+ const char *params,
+ struct rte_tel_data *d)
+{
+ struct rte_eth_txmode *txmode;
+ struct rte_eth_conf dev_conf;
+ unsigned long port_id;
+ int offload, ret;
+ char *end_param;
+
+ if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+ return -EINVAL;
+
+ port_id = strtoul(params, &end_param, 0);
+ if (*end_param != '\0')
+ RTE_ETHDEV_LOG(NOTICE,
+ "Extra parameters passed to ethdev telemetry command, ignoring\n");
+
+ if (port_id >= UINT16_MAX || !rte_eth_dev_is_valid_port(port_id))
+ return -EINVAL;
+
+ ret = rte_eth_dev_conf_get(port_id, &dev_conf);
+ if (ret != 0) {
+ RTE_ETHDEV_LOG(ERR,
+ "Failed to get device configuration, ret = %d\n", ret);
+ return ret;
+ }
+
+ txmode = &dev_conf.txmode;
+ rte_tel_data_start_dict(d);
+ rte_tel_data_add_dict_uint(d, "pvid", txmode->pvid);
+ rte_tel_data_add_dict_uint(d, "hw_vlan_reject_tagged",
+ txmode->hw_vlan_reject_tagged);
+ rte_tel_data_add_dict_uint(d, "hw_vlan_reject_untagged",
+ txmode->hw_vlan_reject_untagged);
+ rte_tel_data_add_dict_uint(d, "hw_vlan_insert_pvid",
+ txmode->hw_vlan_insert_pvid);
+
+ offload = rte_eth_dev_get_vlan_offload(port_id);
+ rte_tel_data_add_dict_string(d, "VLAN_STRIP",
+ ((offload & RTE_ETH_VLAN_STRIP_OFFLOAD) != 0) ? "on" : "off");
+ rte_tel_data_add_dict_string(d, "VLAN_EXTEND",
+ ((offload & RTE_ETH_VLAN_EXTEND_OFFLOAD) != 0) ? "on" : "off");
+ rte_tel_data_add_dict_string(d, "QINQ_STRIP",
+ ((offload & RTE_ETH_QINQ_STRIP_OFFLOAD) != 0) ? "on" : "off");
+ rte_tel_data_add_dict_string(d, "VLAN_FILTER",
+ ((offload & RTE_ETH_VLAN_FILTER_OFFLOAD) != 0) ? "on" : "off");
+
+ return eth_dev_add_vlan_id(port_id, d);
+}
+
RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO);
RTE_INIT(ethdev_init_telemetry)
@@ -7694,4 +7806,6 @@ RTE_INIT(ethdev_init_telemetry)
"Returns RSS info for a port. Parameters: unsigned port_id");
rte_telemetry_register_cmd("/ethdev/fec", eth_dev_handle_port_fec,
"Returns FEC info for a port. Parameters: unsigned port_id");
+ rte_telemetry_register_cmd("/ethdev/vlan", eth_dev_handle_port_vlan,
+ "Returns VLAN info for a port. Parameters: unsigned port_id");
}
--
2.33.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 00/10] support telemetry query ethdev info
2023-05-30 9:05 [PATCH 00/10] support telemetry query ethdev info Jie Hai
` (9 preceding siblings ...)
2023-05-30 9:05 ` [PATCH 10/10] ethdev: support telemetry query VLAN info Jie Hai
@ 2023-06-01 12:05 ` Ferruh Yigit
2023-06-01 12:23 ` Jie Hai
2023-06-01 14:36 ` Ferruh Yigit
2023-06-07 7:41 ` [PATCH v2 00/13] " Jie Hai
12 siblings, 1 reply; 36+ messages in thread
From: Ferruh Yigit @ 2023-06-01 12:05 UTC (permalink / raw)
To: Jie Hai; +Cc: dev, liudongdong3
On 5/30/2023 10:05 AM, Jie Hai wrote:
> Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
>
>
> This patchset supports querying information about ethdev.
> The information includes MAC addresses, RxTx offload, flow ctrl,
> Rx|Tx queue, firmware version, DCB, RSS, FEC, VLAN, etc.
>
>
> Dengdui Huang (1):
> ethdev: support telemetry query MAC addresses
>
> Jie Hai (9):
> ethdev: support RxTx offload display
> ethdev: support telemetry query flow ctrl info
> ethdev: support telemetry query Rx queue info
> ethdev: support telemetry query Tx queue info
> ethdev: add firmware version in telemetry info command
> ethdev: support telemetry query DCB info
> ethdev: support telemetry query RSS info
> ethdev: support telemetry query FEC info
> ethdev: support telemetry query VLAN info
>
Hi Jie,
There are build errors, reported by CI, and %l usage related checkpatch
warnings, can you please fix them in next version?
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 00/10] support telemetry query ethdev info
2023-06-01 12:05 ` [PATCH 00/10] support telemetry query ethdev info Ferruh Yigit
@ 2023-06-01 12:23 ` Jie Hai
0 siblings, 0 replies; 36+ messages in thread
From: Jie Hai @ 2023-06-01 12:23 UTC (permalink / raw)
To: Ferruh Yigit; +Cc: dev, liudongdong (C)
On 2023/6/1 20:05, Ferruh Yigit wrote:
> On 5/30/2023 10:05 AM, Jie Hai wrote:
>> Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
>>
>>
>> This patchset supports querying information about ethdev.
>> The information includes MAC addresses, RxTx offload, flow ctrl,
>> Rx|Tx queue, firmware version, DCB, RSS, FEC, VLAN, etc.
>>
>>
>> Dengdui Huang (1):
>> ethdev: support telemetry query MAC addresses
>>
>> Jie Hai (9):
>> ethdev: support RxTx offload display
>> ethdev: support telemetry query flow ctrl info
>> ethdev: support telemetry query Rx queue info
>> ethdev: support telemetry query Tx queue info
>> ethdev: add firmware version in telemetry info command
>> ethdev: support telemetry query DCB info
>> ethdev: support telemetry query RSS info
>> ethdev: support telemetry query FEC info
>> ethdev: support telemetry query VLAN info
>>
> Hi Jie,
>
> There are build errors, reported by CI, and %l usage related checkpatch
> warnings, can you please fix them in next version?
>
>
Hi Ferruh,
Thanks for your reply, I will fix them in V2.
Jie Hai.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 00/10] support telemetry query ethdev info
2023-05-30 9:05 [PATCH 00/10] support telemetry query ethdev info Jie Hai
` (10 preceding siblings ...)
2023-06-01 12:05 ` [PATCH 00/10] support telemetry query ethdev info Ferruh Yigit
@ 2023-06-01 14:36 ` Ferruh Yigit
2023-06-05 6:19 ` Jie Hai
2023-06-07 7:41 ` [PATCH v2 00/13] " Jie Hai
12 siblings, 1 reply; 36+ messages in thread
From: Ferruh Yigit @ 2023-06-01 14:36 UTC (permalink / raw)
To: Jie Hai; +Cc: dev, liudongdong3
On 5/30/2023 10:05 AM, Jie Hai wrote:
> This patchset supports querying information about ethdev.
> The information includes MAC addresses, RxTx offload, flow ctrl,
> Rx|Tx queue, firmware version, DCB, RSS, FEC, VLAN, etc.
>
>
> Dengdui Huang (1):
> ethdev: support telemetry query MAC addresses
>
> Jie Hai (9):
> ethdev: support RxTx offload display
> ethdev: support telemetry query flow ctrl info
> ethdev: support telemetry query Rx queue info
> ethdev: support telemetry query Tx queue info
> ethdev: add firmware version in telemetry info command
> ethdev: support telemetry query DCB info
> ethdev: support telemetry query RSS info
> ethdev: support telemetry query FEC info
> ethdev: support telemetry query VLAN info
>
Hi Jie,
Overall it is good to add more telemetry support, but it is making
'rte_ethdev.c' bigger, specially naming of the static functions that
telemetry handlers use making file confusing.
Can you please create a specific file for telemetry functions?
First you can move the existing ones and later add your patches.
Also there is a common part that reads and verifies port_id, I think
that part can be extracted to a common function, I will comment on it in
one of the patches.
Thanks,
ferruh
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 01/10] ethdev: support telemetry query MAC addresses
2023-05-30 9:05 ` [PATCH 01/10] ethdev: support telemetry query MAC addresses Jie Hai
@ 2023-06-01 14:39 ` Ferruh Yigit
0 siblings, 0 replies; 36+ messages in thread
From: Ferruh Yigit @ 2023-06-01 14:39 UTC (permalink / raw)
To: Jie Hai, Thomas Monjalon, Andrew Rybchenko; +Cc: dev, liudongdong3
On 5/30/2023 10:05 AM, Jie Hai wrote:
> +static int
> +eth_dev_handle_port_macs(const char *cmd __rte_unused,
> + const char *params,
> + struct rte_tel_data *d)
> +{
> + char mac_addr[RTE_ETHER_ADDR_FMT_SIZE];
> + struct rte_eth_dev_info dev_info;
> + struct rte_eth_dev *eth_dev;
> + unsigned long port_id;
> + char *end_param;
> + uint32_t i;
> + int ret;
> +
> + if (params == NULL || strlen(params) == 0 || !isdigit(*params))
> + return -EINVAL;
> +
> + port_id = strtoul(params, &end_param, 0);
> + if (*end_param != '\0')
> + RTE_ETHDEV_LOG(NOTICE,
> + "Extra parameters passed to ethdev telemetry command, ignoring");
> +
> + if (port_id >= UINT16_MAX)
> + return -EINVAL;
> +
Above part is common in many telemetry handle functions, what about
extracting it as a function?
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH 00/10] support telemetry query ethdev info
2023-06-01 14:36 ` Ferruh Yigit
@ 2023-06-05 6:19 ` Jie Hai
0 siblings, 0 replies; 36+ messages in thread
From: Jie Hai @ 2023-06-05 6:19 UTC (permalink / raw)
To: Ferruh Yigit; +Cc: dev, liudongdong3
On 2023/6/1 22:36, Ferruh Yigit wrote:
> On 5/30/2023 10:05 AM, Jie Hai wrote:
>> This patchset supports querying information about ethdev.
>> The information includes MAC addresses, RxTx offload, flow ctrl,
>> Rx|Tx queue, firmware version, DCB, RSS, FEC, VLAN, etc.
>>
>>
>> Dengdui Huang (1):
>> ethdev: support telemetry query MAC addresses
>>
>> Jie Hai (9):
>> ethdev: support RxTx offload display
>> ethdev: support telemetry query flow ctrl info
>> ethdev: support telemetry query Rx queue info
>> ethdev: support telemetry query Tx queue info
>> ethdev: add firmware version in telemetry info command
>> ethdev: support telemetry query DCB info
>> ethdev: support telemetry query RSS info
>> ethdev: support telemetry query FEC info
>> ethdev: support telemetry query VLAN info
>>
>
> Hi Jie,
>
> Overall it is good to add more telemetry support, but it is making
> 'rte_ethdev.c' bigger, specially naming of the static functions that
> telemetry handlers use making file confusing.
> Can you please create a specific file for telemetry functions?
>
> First you can move the existing ones and later add your patches.
>
> Also there is a common part that reads and verifies port_id, I think
> that part can be extracted to a common function, I will comment on it in
> one of the patches.
>
> Thanks,
> ferruh
> .
Hi ferruh,
Thanks for your review, I will fix them in the next version.
Thanks,
Jie Hai
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v2 00/13] support telemetry query ethdev info
2023-05-30 9:05 [PATCH 00/10] support telemetry query ethdev info Jie Hai
` (11 preceding siblings ...)
2023-06-01 14:36 ` Ferruh Yigit
@ 2023-06-07 7:41 ` Jie Hai
2023-06-07 7:41 ` [PATCH v2 01/13] ethdev: fix incorrect argument of calloc Jie Hai
` (13 more replies)
12 siblings, 14 replies; 36+ messages in thread
From: Jie Hai @ 2023-06-07 7:41 UTC (permalink / raw)
Cc: dev, liudongdong3
This patchset supports querying information about ethdev.
The information includes MAC addresses, RxTx offload, flow ctrl,
Rx|Tx queue, firmware version, DCB, RSS, FEC, VLAN, etc.
v1->v2:
1. Fix incorrect argument of calloc.
2. Extract telemetry codes to a file.
3. Extract codes parsing port id as a function.
4. Use malloc instead of rte_malloc.
5. Fix codecheck warnings and build errors reported by CI.
6. Use 'int' instead of 'unsigned' in help info.
Dengdui Huang (1):
ethdev: support telemetry query MAC addresses
Jie Hai (12):
ethdev: fix incorrect argument of calloc
ethdev: extract telemetry codes to a file
ethdev: extract codes parsing port ID as a function
ethdev: support RxTx offload display
ethdev: support telemetry query flow ctrl info
ethdev: support telemetry query Rx queue info
ethdev: support telemetry query Tx queue info
ethdev: add firmware version in telemetry info command
ethdev: support telemetry query DCB info
ethdev: support telemetry query RSS info
ethdev: support telemetry query FEC info
ethdev: support telemetry query VLAN info
lib/ethdev/meson.build | 1 +
lib/ethdev/rte_ethdev.c | 332 ---------
lib/ethdev/rte_ethdev_telemetry.c | 1063 +++++++++++++++++++++++++++++
lib/ethdev/sff_telemetry.c | 4 +-
4 files changed, 1066 insertions(+), 334 deletions(-)
create mode 100644 lib/ethdev/rte_ethdev_telemetry.c
--
2.33.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v2 01/13] ethdev: fix incorrect argument of calloc
2023-06-07 7:41 ` [PATCH v2 00/13] " Jie Hai
@ 2023-06-07 7:41 ` Jie Hai
2023-06-07 11:35 ` Ferruh Yigit
2023-06-07 7:41 ` [PATCH v2 02/13] ethdev: extract telemetry codes to a file Jie Hai
` (12 subsequent siblings)
13 siblings, 1 reply; 36+ messages in thread
From: Jie Hai @ 2023-06-07 7:41 UTC (permalink / raw)
To: Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko,
Morten Brørup, Chengwen Feng
Cc: dev, liudongdong3
The 'calloc' uses number as first argument, sizeof is generally wrong.
This patch fixes it.
Fixes: 8af559f94cef ("ethdev: support telemetry private dump")
Cc: stable@dpdk.org
Signed-off-by: Jie Hai <haijie1@huawei.com>
---
lib/ethdev/rte_ethdev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index d46e74504e64..503d500429c0 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -6548,7 +6548,7 @@ eth_dev_handle_port_dump_priv(const char *cmd __rte_unused,
if (!rte_eth_dev_is_valid_port(port_id))
return -EINVAL;
- buf = calloc(sizeof(char), RTE_TEL_MAX_SINGLE_STRING_LEN);
+ buf = calloc(RTE_TEL_MAX_SINGLE_STRING_LEN, sizeof(char));
if (buf == NULL)
return -ENOMEM;
--
2.33.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v2 02/13] ethdev: extract telemetry codes to a file
2023-06-07 7:41 ` [PATCH v2 00/13] " Jie Hai
2023-06-07 7:41 ` [PATCH v2 01/13] ethdev: fix incorrect argument of calloc Jie Hai
@ 2023-06-07 7:41 ` Jie Hai
2023-06-07 11:37 ` Ferruh Yigit
2023-06-07 7:41 ` [PATCH v2 03/13] ethdev: extract codes parsing port ID as a function Jie Hai
` (11 subsequent siblings)
13 siblings, 1 reply; 36+ messages in thread
From: Jie Hai @ 2023-06-07 7:41 UTC (permalink / raw)
To: Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko; +Cc: dev, liudongdong3
This patch extracts telemetry related codes in rte_ethdev.c
to a new file rte_ethdev_telemetry.c.
Signed-off-by: Jie Hai <haijie1@huawei.com>
---
lib/ethdev/meson.build | 1 +
lib/ethdev/rte_ethdev.c | 332 ----------------------------
lib/ethdev/rte_ethdev_telemetry.c | 344 ++++++++++++++++++++++++++++++
3 files changed, 345 insertions(+), 332 deletions(-)
create mode 100644 lib/ethdev/rte_ethdev_telemetry.c
diff --git a/lib/ethdev/meson.build b/lib/ethdev/meson.build
index 1ba0fac5c0f0..3497aa154844 100644
--- a/lib/ethdev/meson.build
+++ b/lib/ethdev/meson.build
@@ -9,6 +9,7 @@ sources = files(
'rte_class_eth.c',
'rte_ethdev.c',
'rte_ethdev_cman.c',
+ 'rte_ethdev_telemetry.c',
'rte_flow.c',
'rte_mtr.c',
'rte_tm.c',
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index 503d500429c0..47a757a8fa93 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -6380,317 +6380,6 @@ rte_eth_dev_pool_ops_supported(uint16_t port_id, const char *pool)
return ret;
}
-static int
-eth_dev_handle_port_list(const char *cmd __rte_unused,
- const char *params __rte_unused,
- struct rte_tel_data *d)
-{
- int port_id;
-
- rte_tel_data_start_array(d, RTE_TEL_INT_VAL);
- RTE_ETH_FOREACH_DEV(port_id)
- rte_tel_data_add_array_int(d, port_id);
- return 0;
-}
-
-static void
-eth_dev_add_port_queue_stats(struct rte_tel_data *d, uint64_t *q_stats,
- const char *stat_name)
-{
- int q;
- struct rte_tel_data *q_data = rte_tel_data_alloc();
- if (q_data == NULL)
- return;
- rte_tel_data_start_array(q_data, RTE_TEL_UINT_VAL);
- for (q = 0; q < RTE_ETHDEV_QUEUE_STAT_CNTRS; q++)
- rte_tel_data_add_array_uint(q_data, q_stats[q]);
- rte_tel_data_add_dict_container(d, stat_name, q_data, 0);
-}
-
-#define ADD_DICT_STAT(stats, s) rte_tel_data_add_dict_uint(d, #s, stats.s)
-
-static int
-eth_dev_handle_port_stats(const char *cmd __rte_unused,
- const char *params,
- struct rte_tel_data *d)
-{
- struct rte_eth_stats stats;
- int port_id, ret;
-
- if (params == NULL || strlen(params) == 0 || !isdigit(*params))
- return -1;
-
- port_id = atoi(params);
- if (!rte_eth_dev_is_valid_port(port_id))
- return -1;
-
- ret = rte_eth_stats_get(port_id, &stats);
- if (ret < 0)
- return -1;
-
- rte_tel_data_start_dict(d);
- ADD_DICT_STAT(stats, ipackets);
- ADD_DICT_STAT(stats, opackets);
- ADD_DICT_STAT(stats, ibytes);
- ADD_DICT_STAT(stats, obytes);
- ADD_DICT_STAT(stats, imissed);
- ADD_DICT_STAT(stats, ierrors);
- ADD_DICT_STAT(stats, oerrors);
- ADD_DICT_STAT(stats, rx_nombuf);
- eth_dev_add_port_queue_stats(d, stats.q_ipackets, "q_ipackets");
- eth_dev_add_port_queue_stats(d, stats.q_opackets, "q_opackets");
- eth_dev_add_port_queue_stats(d, stats.q_ibytes, "q_ibytes");
- eth_dev_add_port_queue_stats(d, stats.q_obytes, "q_obytes");
- eth_dev_add_port_queue_stats(d, stats.q_errors, "q_errors");
-
- return 0;
-}
-
-static int
-eth_dev_parse_hide_zero(const char *key, const char *value, void *extra_args)
-{
- RTE_SET_USED(key);
-
- if (value == NULL)
- return -1;
-
- if (strcmp(value, "true") == 0)
- *(bool *)extra_args = true;
- else if (strcmp(value, "false") == 0)
- *(bool *)extra_args = false;
- else
- return -1;
-
- return 0;
-}
-
-static int
-eth_dev_handle_port_xstats(const char *cmd __rte_unused,
- const char *params,
- struct rte_tel_data *d)
-{
- const char *const valid_keys[] = { "hide_zero", NULL };
- struct rte_eth_xstat *eth_xstats;
- struct rte_eth_xstat_name *xstat_names;
- struct rte_kvargs *kvlist;
- int port_id, num_xstats;
- bool hide_zero = false;
- char *end_param;
- int i, ret;
-
- if (params == NULL || strlen(params) == 0 || !isdigit(*params))
- return -1;
-
- port_id = strtoul(params, &end_param, 0);
- if (!rte_eth_dev_is_valid_port(port_id))
- return -1;
-
- if (*end_param != '\0') {
- kvlist = rte_kvargs_parse(end_param, valid_keys);
- ret = rte_kvargs_process(kvlist, NULL, eth_dev_parse_hide_zero, &hide_zero);
- if (kvlist == NULL || ret != 0)
- RTE_ETHDEV_LOG(NOTICE,
- "Unknown extra parameters passed to ethdev telemetry command, ignoring\n");
- rte_kvargs_free(kvlist);
- }
-
- num_xstats = rte_eth_xstats_get(port_id, NULL, 0);
- if (num_xstats < 0)
- return -1;
-
- /* use one malloc for both names and stats */
- eth_xstats = malloc((sizeof(struct rte_eth_xstat) +
- sizeof(struct rte_eth_xstat_name)) * num_xstats);
- if (eth_xstats == NULL)
- return -1;
- xstat_names = (void *)ð_xstats[num_xstats];
-
- ret = rte_eth_xstats_get_names(port_id, xstat_names, num_xstats);
- if (ret < 0 || ret > num_xstats) {
- free(eth_xstats);
- return -1;
- }
-
- ret = rte_eth_xstats_get(port_id, eth_xstats, num_xstats);
- if (ret < 0 || ret > num_xstats) {
- free(eth_xstats);
- return -1;
- }
-
- rte_tel_data_start_dict(d);
- for (i = 0; i < num_xstats; i++) {
- if (hide_zero && eth_xstats[i].value == 0)
- continue;
- rte_tel_data_add_dict_uint(d, xstat_names[i].name,
- eth_xstats[i].value);
- }
- free(eth_xstats);
- return 0;
-}
-
-#ifndef RTE_EXEC_ENV_WINDOWS
-static int
-eth_dev_handle_port_dump_priv(const char *cmd __rte_unused,
- const char *params,
- struct rte_tel_data *d)
-{
- char *buf, *end_param;
- int port_id, ret;
- FILE *f;
-
- if (params == NULL || strlen(params) == 0 || !isdigit(*params))
- return -EINVAL;
-
- port_id = strtoul(params, &end_param, 0);
- if (*end_param != '\0')
- RTE_ETHDEV_LOG(NOTICE,
- "Extra parameters passed to ethdev telemetry command, ignoring");
- if (!rte_eth_dev_is_valid_port(port_id))
- return -EINVAL;
-
- buf = calloc(RTE_TEL_MAX_SINGLE_STRING_LEN, sizeof(char));
- if (buf == NULL)
- return -ENOMEM;
-
- f = fmemopen(buf, RTE_TEL_MAX_SINGLE_STRING_LEN - 1, "w+");
- if (f == NULL) {
- free(buf);
- return -EINVAL;
- }
-
- ret = rte_eth_dev_priv_dump(port_id, f);
- fclose(f);
- if (ret == 0) {
- rte_tel_data_start_dict(d);
- rte_tel_data_string(d, buf);
- }
-
- free(buf);
- return 0;
-}
-#endif /* !RTE_EXEC_ENV_WINDOWS */
-
-static int
-eth_dev_handle_port_link_status(const char *cmd __rte_unused,
- const char *params,
- struct rte_tel_data *d)
-{
- static const char *status_str = "status";
- int ret, port_id;
- struct rte_eth_link link;
- char *end_param;
-
- if (params == NULL || strlen(params) == 0 || !isdigit(*params))
- return -1;
-
- port_id = strtoul(params, &end_param, 0);
- if (*end_param != '\0')
- RTE_ETHDEV_LOG(NOTICE,
- "Extra parameters passed to ethdev telemetry command, ignoring");
- if (!rte_eth_dev_is_valid_port(port_id))
- return -1;
-
- ret = rte_eth_link_get_nowait(port_id, &link);
- if (ret < 0)
- return -1;
-
- rte_tel_data_start_dict(d);
- if (!link.link_status) {
- rte_tel_data_add_dict_string(d, status_str, "DOWN");
- return 0;
- }
- rte_tel_data_add_dict_string(d, status_str, "UP");
- rte_tel_data_add_dict_uint(d, "speed", link.link_speed);
- rte_tel_data_add_dict_string(d, "duplex",
- (link.link_duplex == RTE_ETH_LINK_FULL_DUPLEX) ?
- "full-duplex" : "half-duplex");
- return 0;
-}
-
-static int
-eth_dev_handle_port_info(const char *cmd __rte_unused,
- const char *params,
- struct rte_tel_data *d)
-{
- struct rte_tel_data *rxq_state, *txq_state;
- char mac_addr[RTE_ETHER_ADDR_FMT_SIZE];
- struct rte_eth_dev *eth_dev;
- char *end_param;
- int port_id, i;
-
- if (params == NULL || strlen(params) == 0 || !isdigit(*params))
- return -1;
-
- port_id = strtoul(params, &end_param, 0);
- if (*end_param != '\0')
- RTE_ETHDEV_LOG(NOTICE,
- "Extra parameters passed to ethdev telemetry command, ignoring");
-
- if (!rte_eth_dev_is_valid_port(port_id))
- return -EINVAL;
-
- eth_dev = &rte_eth_devices[port_id];
-
- rxq_state = rte_tel_data_alloc();
- if (!rxq_state)
- return -ENOMEM;
-
- txq_state = rte_tel_data_alloc();
- if (!txq_state) {
- rte_tel_data_free(rxq_state);
- return -ENOMEM;
- }
-
- rte_tel_data_start_dict(d);
- rte_tel_data_add_dict_string(d, "name", eth_dev->data->name);
- rte_tel_data_add_dict_int(d, "state", eth_dev->state);
- rte_tel_data_add_dict_int(d, "nb_rx_queues",
- eth_dev->data->nb_rx_queues);
- rte_tel_data_add_dict_int(d, "nb_tx_queues",
- eth_dev->data->nb_tx_queues);
- rte_tel_data_add_dict_int(d, "port_id", eth_dev->data->port_id);
- rte_tel_data_add_dict_int(d, "mtu", eth_dev->data->mtu);
- rte_tel_data_add_dict_uint(d, "rx_mbuf_size_min",
- eth_dev->data->min_rx_buf_size);
- rte_ether_format_addr(mac_addr, sizeof(mac_addr),
- eth_dev->data->mac_addrs);
- rte_tel_data_add_dict_string(d, "mac_addr", mac_addr);
- rte_tel_data_add_dict_int(d, "promiscuous",
- eth_dev->data->promiscuous);
- rte_tel_data_add_dict_int(d, "scattered_rx",
- eth_dev->data->scattered_rx);
- rte_tel_data_add_dict_int(d, "all_multicast",
- eth_dev->data->all_multicast);
- rte_tel_data_add_dict_int(d, "dev_started", eth_dev->data->dev_started);
- rte_tel_data_add_dict_int(d, "lro", eth_dev->data->lro);
- rte_tel_data_add_dict_int(d, "dev_configured",
- eth_dev->data->dev_configured);
-
- rte_tel_data_start_array(rxq_state, RTE_TEL_INT_VAL);
- for (i = 0; i < eth_dev->data->nb_rx_queues; i++)
- rte_tel_data_add_array_int(rxq_state,
- eth_dev->data->rx_queue_state[i]);
-
- rte_tel_data_start_array(txq_state, RTE_TEL_INT_VAL);
- for (i = 0; i < eth_dev->data->nb_tx_queues; i++)
- rte_tel_data_add_array_int(txq_state,
- eth_dev->data->tx_queue_state[i]);
-
- rte_tel_data_add_dict_container(d, "rxq_state", rxq_state, 0);
- rte_tel_data_add_dict_container(d, "txq_state", txq_state, 0);
- rte_tel_data_add_dict_int(d, "numa_node", eth_dev->data->numa_node);
- rte_tel_data_add_dict_uint_hex(d, "dev_flags",
- eth_dev->data->dev_flags, 0);
- rte_tel_data_add_dict_uint_hex(d, "rx_offloads",
- eth_dev->data->dev_conf.rxmode.offloads, 0);
- rte_tel_data_add_dict_uint_hex(d, "tx_offloads",
- eth_dev->data->dev_conf.txmode.offloads, 0);
- rte_tel_data_add_dict_uint_hex(d, "ethdev_rss_hf",
- eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf, 0);
-
- return 0;
-}
-
int
rte_eth_representor_info_get(uint16_t port_id,
struct rte_eth_representor_info *info)
@@ -7033,24 +6722,3 @@ int rte_eth_dev_map_aggr_tx_affinity(uint16_t port_id, uint16_t tx_queue_id,
}
RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO);
-
-RTE_INIT(ethdev_init_telemetry)
-{
- rte_telemetry_register_cmd("/ethdev/list", eth_dev_handle_port_list,
- "Returns list of available ethdev ports. Takes no parameters");
- rte_telemetry_register_cmd("/ethdev/stats", eth_dev_handle_port_stats,
- "Returns the common stats for a port. Parameters: int port_id");
- rte_telemetry_register_cmd("/ethdev/xstats", eth_dev_handle_port_xstats,
- "Returns the extended stats for a port. Parameters: int port_id,hide_zero=true|false(Optional for indicates hide zero xstats)");
-#ifndef RTE_EXEC_ENV_WINDOWS
- rte_telemetry_register_cmd("/ethdev/dump_priv", eth_dev_handle_port_dump_priv,
- "Returns dump private information for a port. Parameters: int port_id");
-#endif
- rte_telemetry_register_cmd("/ethdev/link_status",
- eth_dev_handle_port_link_status,
- "Returns the link status for a port. Parameters: int port_id");
- rte_telemetry_register_cmd("/ethdev/info", eth_dev_handle_port_info,
- "Returns the device info for a port. Parameters: int port_id");
- rte_telemetry_register_cmd("/ethdev/module_eeprom", eth_dev_handle_port_module_eeprom,
- "Returns module EEPROM info with SFF specs. Parameters: int port_id");
-}
diff --git a/lib/ethdev/rte_ethdev_telemetry.c b/lib/ethdev/rte_ethdev_telemetry.c
new file mode 100644
index 000000000000..ec8e48877187
--- /dev/null
+++ b/lib/ethdev/rte_ethdev_telemetry.c
@@ -0,0 +1,344 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2017 Intel Corporation
+ */
+#include <ctype.h>
+#include <stdlib.h>
+
+#include <rte_kvargs.h>
+#include <rte_telemetry.h>
+
+#include "rte_ethdev.h"
+#include "ethdev_driver.h"
+#include "sff_telemetry.h"
+
+static int
+eth_dev_handle_port_list(const char *cmd __rte_unused,
+ const char *params __rte_unused,
+ struct rte_tel_data *d)
+{
+ int port_id;
+
+ rte_tel_data_start_array(d, RTE_TEL_INT_VAL);
+ RTE_ETH_FOREACH_DEV(port_id)
+ rte_tel_data_add_array_int(d, port_id);
+ return 0;
+}
+
+static void
+eth_dev_add_port_queue_stats(struct rte_tel_data *d, uint64_t *q_stats,
+ const char *stat_name)
+{
+ int q;
+ struct rte_tel_data *q_data = rte_tel_data_alloc();
+ if (q_data == NULL)
+ return;
+ rte_tel_data_start_array(q_data, RTE_TEL_UINT_VAL);
+ for (q = 0; q < RTE_ETHDEV_QUEUE_STAT_CNTRS; q++)
+ rte_tel_data_add_array_uint(q_data, q_stats[q]);
+ rte_tel_data_add_dict_container(d, stat_name, q_data, 0);
+}
+
+static int
+eth_dev_parse_hide_zero(const char *key, const char *value, void *extra_args)
+{
+ RTE_SET_USED(key);
+
+ if (value == NULL)
+ return -1;
+
+ if (strcmp(value, "true") == 0)
+ *(bool *)extra_args = true;
+ else if (strcmp(value, "false") == 0)
+ *(bool *)extra_args = false;
+ else
+ return -1;
+
+ return 0;
+}
+
+#define ADD_DICT_STAT(stats, s) rte_tel_data_add_dict_uint(d, #s, stats.s)
+
+static int
+eth_dev_handle_port_stats(const char *cmd __rte_unused,
+ const char *params,
+ struct rte_tel_data *d)
+{
+ struct rte_eth_stats stats;
+ int port_id, ret;
+
+ if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+ return -1;
+
+ port_id = atoi(params);
+ if (!rte_eth_dev_is_valid_port(port_id))
+ return -1;
+
+ ret = rte_eth_stats_get(port_id, &stats);
+ if (ret < 0)
+ return -1;
+
+ rte_tel_data_start_dict(d);
+ ADD_DICT_STAT(stats, ipackets);
+ ADD_DICT_STAT(stats, opackets);
+ ADD_DICT_STAT(stats, ibytes);
+ ADD_DICT_STAT(stats, obytes);
+ ADD_DICT_STAT(stats, imissed);
+ ADD_DICT_STAT(stats, ierrors);
+ ADD_DICT_STAT(stats, oerrors);
+ ADD_DICT_STAT(stats, rx_nombuf);
+ eth_dev_add_port_queue_stats(d, stats.q_ipackets, "q_ipackets");
+ eth_dev_add_port_queue_stats(d, stats.q_opackets, "q_opackets");
+ eth_dev_add_port_queue_stats(d, stats.q_ibytes, "q_ibytes");
+ eth_dev_add_port_queue_stats(d, stats.q_obytes, "q_obytes");
+ eth_dev_add_port_queue_stats(d, stats.q_errors, "q_errors");
+
+ return 0;
+}
+
+static int
+eth_dev_handle_port_xstats(const char *cmd __rte_unused,
+ const char *params,
+ struct rte_tel_data *d)
+{
+ const char *const valid_keys[] = { "hide_zero", NULL };
+ struct rte_eth_xstat *eth_xstats;
+ struct rte_eth_xstat_name *xstat_names;
+ struct rte_kvargs *kvlist;
+ int port_id, num_xstats;
+ bool hide_zero = false;
+ char *end_param;
+ int i, ret;
+
+ if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+ return -1;
+
+ port_id = strtoul(params, &end_param, 0);
+ if (!rte_eth_dev_is_valid_port(port_id))
+ return -1;
+
+ if (*end_param != '\0') {
+ kvlist = rte_kvargs_parse(end_param, valid_keys);
+ ret = rte_kvargs_process(kvlist, NULL, eth_dev_parse_hide_zero, &hide_zero);
+ if (kvlist == NULL || ret != 0)
+ RTE_ETHDEV_LOG(NOTICE,
+ "Unknown extra parameters passed to ethdev telemetry command, ignoring\n");
+ rte_kvargs_free(kvlist);
+ }
+
+ num_xstats = rte_eth_xstats_get(port_id, NULL, 0);
+ if (num_xstats < 0)
+ return -1;
+
+ /* use one malloc for both names and stats */
+ eth_xstats = malloc((sizeof(struct rte_eth_xstat) +
+ sizeof(struct rte_eth_xstat_name)) * num_xstats);
+ if (eth_xstats == NULL)
+ return -1;
+ xstat_names = (void *)ð_xstats[num_xstats];
+
+ ret = rte_eth_xstats_get_names(port_id, xstat_names, num_xstats);
+ if (ret < 0 || ret > num_xstats) {
+ free(eth_xstats);
+ return -1;
+ }
+
+ ret = rte_eth_xstats_get(port_id, eth_xstats, num_xstats);
+ if (ret < 0 || ret > num_xstats) {
+ free(eth_xstats);
+ return -1;
+ }
+
+ rte_tel_data_start_dict(d);
+ for (i = 0; i < num_xstats; i++) {
+ if (hide_zero && eth_xstats[i].value == 0)
+ continue;
+ rte_tel_data_add_dict_uint(d, xstat_names[i].name,
+ eth_xstats[i].value);
+ }
+ free(eth_xstats);
+ return 0;
+}
+
+#ifndef RTE_EXEC_ENV_WINDOWS
+static int
+eth_dev_handle_port_dump_priv(const char *cmd __rte_unused,
+ const char *params,
+ struct rte_tel_data *d)
+{
+ char *buf, *end_param;
+ int port_id, ret;
+ FILE *f;
+
+ if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+ return -EINVAL;
+
+ port_id = strtoul(params, &end_param, 0);
+ if (*end_param != '\0')
+ RTE_ETHDEV_LOG(NOTICE,
+ "Extra parameters passed to ethdev telemetry command, ignoring");
+ if (!rte_eth_dev_is_valid_port(port_id))
+ return -EINVAL;
+
+ buf = calloc(RTE_TEL_MAX_SINGLE_STRING_LEN, sizeof(char));
+ if (buf == NULL)
+ return -ENOMEM;
+
+ f = fmemopen(buf, RTE_TEL_MAX_SINGLE_STRING_LEN - 1, "w+");
+ if (f == NULL) {
+ free(buf);
+ return -EINVAL;
+ }
+
+ ret = rte_eth_dev_priv_dump(port_id, f);
+ fclose(f);
+ if (ret == 0) {
+ rte_tel_data_start_dict(d);
+ rte_tel_data_string(d, buf);
+ }
+
+ free(buf);
+ return 0;
+}
+#endif /* !RTE_EXEC_ENV_WINDOWS */
+
+static int
+eth_dev_handle_port_link_status(const char *cmd __rte_unused,
+ const char *params,
+ struct rte_tel_data *d)
+{
+ static const char *status_str = "status";
+ int ret, port_id;
+ struct rte_eth_link link;
+ char *end_param;
+
+ if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+ return -1;
+
+ port_id = strtoul(params, &end_param, 0);
+ if (*end_param != '\0')
+ RTE_ETHDEV_LOG(NOTICE,
+ "Extra parameters passed to ethdev telemetry command, ignoring");
+ if (!rte_eth_dev_is_valid_port(port_id))
+ return -1;
+
+ ret = rte_eth_link_get_nowait(port_id, &link);
+ if (ret < 0)
+ return -1;
+
+ rte_tel_data_start_dict(d);
+ if (!link.link_status) {
+ rte_tel_data_add_dict_string(d, status_str, "DOWN");
+ return 0;
+ }
+ rte_tel_data_add_dict_string(d, status_str, "UP");
+ rte_tel_data_add_dict_uint(d, "speed", link.link_speed);
+ rte_tel_data_add_dict_string(d, "duplex",
+ (link.link_duplex == RTE_ETH_LINK_FULL_DUPLEX) ?
+ "full-duplex" : "half-duplex");
+ return 0;
+}
+
+static int
+eth_dev_handle_port_info(const char *cmd __rte_unused,
+ const char *params,
+ struct rte_tel_data *d)
+{
+ struct rte_tel_data *rxq_state, *txq_state;
+ char mac_addr[RTE_ETHER_ADDR_FMT_SIZE];
+ struct rte_eth_dev *eth_dev;
+ char *end_param;
+ int port_id, i;
+
+ if (params == NULL || strlen(params) == 0 || !isdigit(*params))
+ return -1;
+
+ port_id = strtoul(params, &end_param, 0);
+ if (*end_param != '\0')
+ RTE_ETHDEV_LOG(NOTICE,
+ "Extra parameters passed to ethdev telemetry command, ignoring");
+
+ if (!rte_eth_dev_is_valid_port(port_id))
+ return -EINVAL;
+
+ eth_dev = &rte_eth_devices[port_id];
+
+ rxq_state = rte_tel_data_alloc();
+ if (!rxq_state)
+ return -ENOMEM;
+
+ txq_state = rte_tel_data_alloc();
+ if (!txq_state) {
+ rte_tel_data_free(rxq_state);
+ return -ENOMEM;
+ }
+
+ rte_tel_data_start_dict(d);
+ rte_tel_data_add_dict_string(d, "name", eth_dev->data->name);
+ rte_tel_data_add_dict_int(d, "state", eth_dev->state);
+ rte_tel_data_add_dict_int(d, "nb_rx_queues",
+ eth_dev->data->nb_rx_queues);
+ rte_tel_data_add_dict_int(d, "nb_tx_queues",
+ eth_dev->data->nb_tx_queues);
+ rte_tel_data_add_dict_int(d, "port_id", eth_dev->data->port_id);
+ rte_tel_data_add_dict_int(d, "mtu", eth_dev->data->mtu);
+ rte_tel_data_add_dict_uint(d, "rx_mbuf_size_min",
+ eth_dev->data->min_rx_buf_size);
+ rte_ether_format_addr(mac_addr, sizeof(mac_addr),
+ eth_dev->data->mac_addrs);
+ rte_tel_data_add_dict_string(d, "mac_addr", mac_addr);
+ rte_tel_data_add_dict_int(d, "promiscuous",
+ eth_dev->data->promiscuous);
+ rte_tel_data_add_dict_int(d, "scattered_rx",
+ eth_dev->data->scattered_rx);
+ rte_tel_data_add_dict_int(d, "all_multicast",
+ eth_dev->data->all_multicast);
+ rte_tel_data_add_dict_int(d, "dev_started", eth_dev->data->dev_started);
+ rte_tel_data_add_dict_int(d, "lro", eth_dev->data->lro);
+ rte_tel_data_add_dict_int(d, "dev_configured",
+ eth_dev->data->dev_configured);
+
+ rte_tel_data_start_array(rxq_state, RTE_TEL_INT_VAL);
+ for (i = 0; i < eth_dev->data->nb_rx_queues; i++)
+ rte_tel_data_add_array_int(rxq_state,
+ eth_dev->data->rx_queue_state[i]);
+
+ rte_tel_data_start_array(txq_state, RTE_TEL_INT_VAL);
+ for (i = 0; i < eth_dev->data->nb_tx_queues; i++)
+ rte_tel_data_add_array_int(txq_state,
+ eth_dev->data->tx_queue_state[i]);
+
+ rte_tel_data_add_dict_container(d, "rxq_state", rxq_state, 0);
+ rte_tel_data_add_dict_container(d, "txq_state", txq_state, 0);
+ rte_tel_data_add_dict_int(d, "numa_node", eth_dev->data->numa_node);
+ rte_tel_data_add_dict_uint_hex(d, "dev_flags",
+ eth_dev->data->dev_flags, 0);
+ rte_tel_data_add_dict_uint_hex(d, "rx_offloads",
+ eth_dev->data->dev_conf.rxmode.offloads, 0);
+ rte_tel_data_add_dict_uint_hex(d, "tx_offloads",
+ eth_dev->data->dev_conf.txmode.offloads, 0);
+ rte_tel_data_add_dict_uint_hex(d, "ethdev_rss_hf",
+ eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf, 0);
+
+ return 0;
+}
+
+RTE_INIT(ethdev_init_telemetry)
+{
+ rte_telemetry_register_cmd("/ethdev/list", eth_dev_handle_port_list,
+ "Returns list of available ethdev ports. Takes no parameters");
+ rte_telemetry_register_cmd("/ethdev/stats", eth_dev_handle_port_stats,
+ "Returns the common stats for a port. Parameters: int port_id");
+ rte_telemetry_register_cmd("/ethdev/xstats", eth_dev_handle_port_xstats,
+ "Returns the extended stats for a port. Parameters: int port_id,hide_zero=true|false(Optional for indicates hide zero xstats)");
+#ifndef RTE_EXEC_ENV_WINDOWS
+ rte_telemetry_register_cmd("/ethdev/dump_priv", eth_dev_handle_port_dump_priv,
+ "Returns dump private information for a port. Parameters: int port_id");
+#endif
+ rte_telemetry_register_cmd("/ethdev/link_status",
+ eth_dev_handle_port_link_status,
+ "Returns the link status for a port. Parameters: int port_id");
+ rte_telemetry_register_cmd("/ethdev/info", eth_dev_handle_port_info,
+ "Returns the device info for a port. Parameters: int port_id");
+ rte_telemetry_register_cmd("/ethdev/module_eeprom", eth_dev_handle_port_module_eeprom,
+ "Returns module EEPROM info with SFF specs. Parameters: int port_id");
+}
--
2.33.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v2 03/13] ethdev: extract codes parsing port ID as a function
2023-06-07 7:41 ` [PATCH v2 00/13] " Jie Hai
2023-06-07 7:41 ` [PATCH v2 01/13] ethdev: fix incorrect argument of calloc Jie Hai
2023-06-07 7:41 ` [PATCH v2 02/13] ethdev: extract telemetry codes to a file Jie Hai
@ 2023-06-07 7:41 ` Jie Hai
2023-06-07 11:37 ` Ferruh Yigit
2023-06-07 7:41 ` [PATCH v2 04/13] ethdev: support telemetry query MAC addresses Jie Hai
` (10 subsequent siblings)
13 siblings, 1 reply; 36+ messages in thread
From: Jie Hai @ 2023-06-07 7:41 UTC (permalink / raw)
To: Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko; +Cc: dev, liudongdong3
This patch extracts codes parsing port_id as a function.
The port id of 'int' or 'unsigned long' type passing as
'uint16_t' may cause truncation, fix it.
Signed-off-by: Jie Hai <haijie1@huawei.com>
---
lib/ethdev/rte_ethdev_telemetry.c | 95 ++++++++++++++++---------------
lib/ethdev/sff_telemetry.c | 4 +-
2 files changed, 52 insertions(+), 47 deletions(-)
diff --git a/lib/ethdev/rte_ethdev_telemetry.c b/lib/ethdev/rte_ethdev_telemetry.c
index ec8e48877187..5e70d0c2a66a 100644
--- a/lib/ethdev/rte_ethdev_telemetry.c
+++ b/lib/ethdev/rte_ethdev_telemetry.c
@@ -11,6 +11,29 @@
#include "ethdev_driver.h"
#include "sff_telemetry.h"
+static int
+eth_dev_parse_port_params(const char *params __rte_unused, uint16_t *port_id,
+ char **end_param, bool has_next)
+{
+ uint64_t pi;
+
+ if (params == NULL || strlen(params) == 0 ||
+ !isdigit(*params) || port_id == NULL)
+ return -EINVAL;
+
+ pi = strtoul(params, end_param, 0);
+ if (**end_param != '\0' && !has_next)
+ RTE_ETHDEV_LOG(NOTICE,
+ "Extra parameters passed to ethdev telemetry command, ignoring\n");
+
+ if (pi >= UINT16_MAX || !rte_eth_dev_is_valid_port(pi))
+ return -EINVAL;
+
+ *port_id = pi;
+
+ return 0;
+}
+
static int
eth_dev_handle_port_list(const char *cmd __rte_unused,
const char *params __rte_unused,
@@ -64,14 +87,13 @@ eth_dev_handle_port_stats(const char *cmd __rte_unused,
struct rte_tel_data *d)
{
struct rte_eth_stats stats;
- int port_id, ret;
-
- if (params == NULL || strlen(params) == 0 || !isdigit(*params))
- return -1;
+ uint16_t port_id;
+ char *end_param;
+ int ret;
- port_id = atoi(params);
- if (!rte_eth_dev_is_valid_port(port_id))
- return -1;
+ ret = eth_dev_parse_port_params(params, &port_id, &end_param, false);
+ if (ret < 0)
+ return ret;
ret = rte_eth_stats_get(port_id, &stats);
if (ret < 0)
@@ -104,17 +126,15 @@ eth_dev_handle_port_xstats(const char *cmd __rte_unused,
struct rte_eth_xstat *eth_xstats;
struct rte_eth_xstat_name *xstat_names;
struct rte_kvargs *kvlist;
- int port_id, num_xstats;
bool hide_zero = false;
+ uint16_t port_id;
char *end_param;
+ int num_xstats;
int i, ret;
- if (params == NULL || strlen(params) == 0 || !isdigit(*params))
- return -1;
-
- port_id = strtoul(params, &end_param, 0);
- if (!rte_eth_dev_is_valid_port(port_id))
- return -1;
+ ret = eth_dev_parse_port_params(params, &port_id, &end_param, true);
+ if (ret < 0)
+ return ret;
if (*end_param != '\0') {
kvlist = rte_kvargs_parse(end_param, valid_keys);
@@ -166,18 +186,13 @@ eth_dev_handle_port_dump_priv(const char *cmd __rte_unused,
struct rte_tel_data *d)
{
char *buf, *end_param;
- int port_id, ret;
+ uint16_t port_id;
+ int ret;
FILE *f;
- if (params == NULL || strlen(params) == 0 || !isdigit(*params))
- return -EINVAL;
-
- port_id = strtoul(params, &end_param, 0);
- if (*end_param != '\0')
- RTE_ETHDEV_LOG(NOTICE,
- "Extra parameters passed to ethdev telemetry command, ignoring");
- if (!rte_eth_dev_is_valid_port(port_id))
- return -EINVAL;
+ ret = eth_dev_parse_port_params(params, &port_id, &end_param, false);
+ if (ret < 0)
+ return ret;
buf = calloc(RTE_TEL_MAX_SINGLE_STRING_LEN, sizeof(char));
if (buf == NULL)
@@ -207,19 +222,14 @@ eth_dev_handle_port_link_status(const char *cmd __rte_unused,
struct rte_tel_data *d)
{
static const char *status_str = "status";
- int ret, port_id;
struct rte_eth_link link;
+ uint16_t port_id;
char *end_param;
+ int ret;
- if (params == NULL || strlen(params) == 0 || !isdigit(*params))
- return -1;
-
- port_id = strtoul(params, &end_param, 0);
- if (*end_param != '\0')
- RTE_ETHDEV_LOG(NOTICE,
- "Extra parameters passed to ethdev telemetry command, ignoring");
- if (!rte_eth_dev_is_valid_port(port_id))
- return -1;
+ ret = eth_dev_parse_port_params(params, &port_id, &end_param, false);
+ if (ret < 0)
+ return ret;
ret = rte_eth_link_get_nowait(port_id, &link);
if (ret < 0)
@@ -246,19 +256,14 @@ eth_dev_handle_port_info(const char *cmd __rte_unused,
struct rte_tel_data *rxq_state, *txq_state;
char mac_addr[RTE_ETHER_ADDR_FMT_SIZE];
struct rte_eth_dev *eth_dev;
+ uint16_t port_id;
char *end_param;
- int port_id, i;
-
- if (params == NULL || strlen(params) == 0 || !isdigit(*params))
- return -1;
+ int ret;
+ int i;
- port_id = strtoul(params, &end_param, 0);
- if (*end_param != '\0')
- RTE_ETHDEV_LOG(NOTICE,
- "Extra parameters passed to ethdev telemetry command, ignoring");
-
- if (!rte_eth_dev_is_valid_port(port_id))
- return -EINVAL;
+ ret = eth_dev_parse_port_params(params, &port_id, &end_param, false);
+ if (ret < 0)
+ return ret;
eth_dev = &rte_eth_devices[port_id];
diff --git a/lib/ethdev/sff_telemetry.c b/lib/ethdev/sff_telemetry.c
index 5923350424c0..f29e7fa882ac 100644
--- a/lib/ethdev/sff_telemetry.c
+++ b/lib/ethdev/sff_telemetry.c
@@ -126,7 +126,7 @@ eth_dev_handle_port_module_eeprom(const char *cmd __rte_unused, const char *para
struct rte_tel_data *d)
{
char *end_param;
- int port_id;
+ uint64_t port_id;
if (params == NULL || strlen(params) == 0 || !isdigit(*params))
return -1;
@@ -134,7 +134,7 @@ eth_dev_handle_port_module_eeprom(const char *cmd __rte_unused, const char *para
errno = 0;
port_id = strtoul(params, &end_param, 0);
- if (errno != 0) {
+ if (errno != 0 || port_id >= UINT16_MAX) {
RTE_ETHDEV_LOG(ERR, "Invalid argument, %d\n", errno);
return -1;
}
--
2.33.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v2 04/13] ethdev: support telemetry query MAC addresses
2023-06-07 7:41 ` [PATCH v2 00/13] " Jie Hai
` (2 preceding siblings ...)
2023-06-07 7:41 ` [PATCH v2 03/13] ethdev: extract codes parsing port ID as a function Jie Hai
@ 2023-06-07 7:41 ` Jie Hai
2023-06-07 7:42 ` [PATCH v2 05/13] ethdev: support RxTx offload display Jie Hai
` (9 subsequent siblings)
13 siblings, 0 replies; 36+ messages in thread
From: Jie Hai @ 2023-06-07 7:41 UTC (permalink / raw)
To: Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko; +Cc: dev, liudongdong3
From: Dengdui Huang <huangdengdui@huawei.com>
This patch support telemetry query MAC addresses for a specific port.
The command is like:
--> /ethdev/macs,0
{
"/ethdev/macs": [
"00:18:2D:00:00:79",
"00:18:2D:00:00:78",
"00:18:2D:00:00:77"
]
}
Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
Signed-off-by: Jie Hai <haijie1@huawei.com>
---
lib/ethdev/rte_ethdev_telemetry.c | 37 +++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/lib/ethdev/rte_ethdev_telemetry.c b/lib/ethdev/rte_ethdev_telemetry.c
index 5e70d0c2a66a..6ba7adf7d08f 100644
--- a/lib/ethdev/rte_ethdev_telemetry.c
+++ b/lib/ethdev/rte_ethdev_telemetry.c
@@ -327,6 +327,41 @@ eth_dev_handle_port_info(const char *cmd __rte_unused,
return 0;
}
+static int
+eth_dev_handle_port_macs(const char *cmd __rte_unused,
+ const char *params,
+ struct rte_tel_data *d)
+{
+ char mac_addr[RTE_ETHER_ADDR_FMT_SIZE];
+ struct rte_eth_dev_info dev_info;
+ struct rte_eth_dev *eth_dev;
+ uint16_t port_id;
+ char *end_param;
+ uint32_t i;
+ int ret;
+
+ ret = eth_dev_parse_port_params(params, &port_id, &end_param, false);
+ if (ret < 0)
+ return ret;
+
+ ret = rte_eth_dev_info_get(port_id, &dev_info);
+ if (ret != 0)
+ return ret;
+
+ eth_dev = &rte_eth_devices[port_id];
+ rte_tel_data_start_array(d, RTE_TEL_STRING_VAL);
+ for (i = 0; i < dev_info.max_mac_addrs; i++) {
+ if (rte_is_zero_ether_addr(ð_dev->data->mac_addrs[i]))
+ continue;
+
+ rte_ether_format_addr(mac_addr, sizeof(mac_addr),
+ ð_dev->data->mac_addrs[i]);
+ rte_tel_data_add_array_string(d, mac_addr);
+ }
+
+ return 0;
+}
+
RTE_INIT(ethdev_init_telemetry)
{
rte_telemetry_register_cmd("/ethdev/list", eth_dev_handle_port_list,
@@ -346,4 +381,6 @@ RTE_INIT(ethdev_init_telemetry)
"Returns the device info for a port. Parameters: int port_id");
rte_telemetry_register_cmd("/ethdev/module_eeprom", eth_dev_handle_port_module_eeprom,
"Returns module EEPROM info with SFF specs. Parameters: int port_id");
+ rte_telemetry_register_cmd("/ethdev/macs", eth_dev_handle_port_macs,
+ "Returns the MAC addresses for a port. Parameters: int port_id");
}
--
2.33.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v2 05/13] ethdev: support RxTx offload display
2023-06-07 7:41 ` [PATCH v2 00/13] " Jie Hai
` (3 preceding siblings ...)
2023-06-07 7:41 ` [PATCH v2 04/13] ethdev: support telemetry query MAC addresses Jie Hai
@ 2023-06-07 7:42 ` Jie Hai
2023-06-07 7:42 ` [PATCH v2 06/13] ethdev: support telemetry query flow ctrl info Jie Hai
` (8 subsequent siblings)
13 siblings, 0 replies; 36+ messages in thread
From: Jie Hai @ 2023-06-07 7:42 UTC (permalink / raw)
To: Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko; +Cc: dev, liudongdong3
Currently, Rx/Tx offloads are displayed in numeric format,
which is not easy to understand. This patch fixes it.
Signed-off-by: Jie Hai <haijie1@huawei.com>
---
lib/ethdev/rte_ethdev_telemetry.c | 64 ++++++++++++++++++++++++++-----
1 file changed, 55 insertions(+), 9 deletions(-)
diff --git a/lib/ethdev/rte_ethdev_telemetry.c b/lib/ethdev/rte_ethdev_telemetry.c
index 6ba7adf7d08f..3b6060a7356a 100644
--- a/lib/ethdev/rte_ethdev_telemetry.c
+++ b/lib/ethdev/rte_ethdev_telemetry.c
@@ -248,11 +248,38 @@ eth_dev_handle_port_link_status(const char *cmd __rte_unused,
return 0;
}
+static void
+eth_dev_parse_rx_offloads(uint64_t offload, struct rte_tel_data *d)
+{
+ uint64_t i;
+
+ rte_tel_data_start_array(d, RTE_TEL_STRING_VAL);
+ for (i = 0; i < CHAR_BIT * sizeof(offload); i++) {
+ if ((offload & RTE_BIT64(i)) != 0)
+ rte_tel_data_add_array_string(d,
+ rte_eth_dev_rx_offload_name(offload & RTE_BIT64(i)));
+ }
+}
+
+static void
+eth_dev_parse_tx_offloads(uint64_t offload, struct rte_tel_data *d)
+{
+ uint64_t i;
+
+ rte_tel_data_start_array(d, RTE_TEL_STRING_VAL);
+ for (i = 0; i < CHAR_BIT * sizeof(offload); i++) {
+ if ((offload & RTE_BIT64(i)) != 0)
+ rte_tel_data_add_array_string(d,
+ rte_eth_dev_tx_offload_name(offload & RTE_BIT64(i)));
+ }
+}
+
static int
eth_dev_handle_port_info(const char *cmd __rte_unused,
const char *params,
struct rte_tel_data *d)
{
+ struct rte_tel_data *rx_offload, *tx_offload;
struct rte_tel_data *rxq_state, *txq_state;
char mac_addr[RTE_ETHER_ADDR_FMT_SIZE];
struct rte_eth_dev *eth_dev;
@@ -268,14 +295,20 @@ eth_dev_handle_port_info(const char *cmd __rte_unused,
eth_dev = &rte_eth_devices[port_id];
rxq_state = rte_tel_data_alloc();
- if (!rxq_state)
+ if (rxq_state == NULL)
return -ENOMEM;
txq_state = rte_tel_data_alloc();
- if (!txq_state) {
- rte_tel_data_free(rxq_state);
- return -ENOMEM;
- }
+ if (txq_state == NULL)
+ goto free_rxq_state;
+
+ rx_offload = rte_tel_data_alloc();
+ if (rx_offload == NULL)
+ goto free_txq_state;
+
+ tx_offload = rte_tel_data_alloc();
+ if (tx_offload == NULL)
+ goto free_rx_offload;
rte_tel_data_start_dict(d);
rte_tel_data_add_dict_string(d, "name", eth_dev->data->name);
@@ -317,14 +350,27 @@ eth_dev_handle_port_info(const char *cmd __rte_unused,
rte_tel_data_add_dict_int(d, "numa_node", eth_dev->data->numa_node);
rte_tel_data_add_dict_uint_hex(d, "dev_flags",
eth_dev->data->dev_flags, 0);
- rte_tel_data_add_dict_uint_hex(d, "rx_offloads",
- eth_dev->data->dev_conf.rxmode.offloads, 0);
- rte_tel_data_add_dict_uint_hex(d, "tx_offloads",
- eth_dev->data->dev_conf.txmode.offloads, 0);
+
+ eth_dev_parse_rx_offloads(eth_dev->data->dev_conf.rxmode.offloads,
+ rx_offload);
+ rte_tel_data_add_dict_container(d, "rx_offloads", rx_offload, 0);
+ eth_dev_parse_tx_offloads(eth_dev->data->dev_conf.txmode.offloads,
+ tx_offload);
+ rte_tel_data_add_dict_container(d, "tx_offloads", tx_offload, 0);
+
rte_tel_data_add_dict_uint_hex(d, "ethdev_rss_hf",
eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf, 0);
return 0;
+
+free_rx_offload:
+ rte_tel_data_free(rx_offload);
+free_txq_state:
+ rte_tel_data_free(txq_state);
+free_rxq_state:
+ rte_tel_data_free(rxq_state);
+
+ return -ENOMEM;
}
static int
--
2.33.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v2 06/13] ethdev: support telemetry query flow ctrl info
2023-06-07 7:41 ` [PATCH v2 00/13] " Jie Hai
` (4 preceding siblings ...)
2023-06-07 7:42 ` [PATCH v2 05/13] ethdev: support RxTx offload display Jie Hai
@ 2023-06-07 7:42 ` Jie Hai
2023-06-07 7:42 ` [PATCH v2 07/13] ethdev: support telemetry query Rx queue info Jie Hai
` (7 subsequent siblings)
13 siblings, 0 replies; 36+ messages in thread
From: Jie Hai @ 2023-06-07 7:42 UTC (permalink / raw)
To: Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko; +Cc: dev, liudongdong3
This patch supports telemetry querying flow control info.
The command is like:
--> /ethdev/flow_ctrl,0
{
"/ethdev/flow_ctrl": {
"high_waterline": "0x0",
"low_waterline": "0x0",
"pause_time": "0xffff",
"send_xon": "off",
"mac_ctrl_frame_fwd": "off",
"rx_pause": "off",
"tx_pause": "off",
"autoneg": "off"
}
}
Signed-off-by: Jie Hai <haijie1@huawei.com>
---
lib/ethdev/rte_ethdev_telemetry.c | 44 +++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/lib/ethdev/rte_ethdev_telemetry.c b/lib/ethdev/rte_ethdev_telemetry.c
index 3b6060a7356a..9847aa528f14 100644
--- a/lib/ethdev/rte_ethdev_telemetry.c
+++ b/lib/ethdev/rte_ethdev_telemetry.c
@@ -408,6 +408,48 @@ eth_dev_handle_port_macs(const char *cmd __rte_unused,
return 0;
}
+static int
+eth_dev_handle_port_flow_ctrl(const char *cmd __rte_unused,
+ const char *params,
+ struct rte_tel_data *d)
+{
+ struct rte_eth_fc_conf fc_conf;
+ uint16_t port_id;
+ char *end_param;
+ bool rx_fc_en;
+ bool tx_fc_en;
+ int ret;
+
+ ret = eth_dev_parse_port_params(params, &port_id, &end_param, false);
+ if (ret < 0)
+ return ret;
+
+ ret = rte_eth_dev_flow_ctrl_get(port_id, &fc_conf);
+ if (ret != 0) {
+ RTE_ETHDEV_LOG(ERR,
+ "Failed to get flow ctrl info, ret = %d\n", ret);
+ return ret;
+ }
+
+ rx_fc_en = fc_conf.mode == RTE_ETH_FC_RX_PAUSE ||
+ fc_conf.mode == RTE_ETH_FC_FULL;
+ tx_fc_en = fc_conf.mode == RTE_ETH_FC_TX_PAUSE ||
+ fc_conf.mode == RTE_ETH_FC_FULL;
+
+ rte_tel_data_start_dict(d);
+ rte_tel_data_add_dict_uint_hex(d, "high_waterline", fc_conf.high_water, 0);
+ rte_tel_data_add_dict_uint_hex(d, "low_waterline", fc_conf.low_water, 0);
+ rte_tel_data_add_dict_uint_hex(d, "pause_time", fc_conf.pause_time, 0);
+ rte_tel_data_add_dict_string(d, "send_xon", fc_conf.send_xon ? "on" : "off");
+ rte_tel_data_add_dict_string(d, "mac_ctrl_frame_fwd",
+ fc_conf.mac_ctrl_frame_fwd ? "on" : "off");
+ rte_tel_data_add_dict_string(d, "rx_pause", rx_fc_en ? "on" : "off");
+ rte_tel_data_add_dict_string(d, "tx_pause", tx_fc_en ? "on" : "off");
+ rte_tel_data_add_dict_string(d, "autoneg", fc_conf.autoneg ? "on" : "off");
+
+ return 0;
+}
+
RTE_INIT(ethdev_init_telemetry)
{
rte_telemetry_register_cmd("/ethdev/list", eth_dev_handle_port_list,
@@ -429,4 +471,6 @@ RTE_INIT(ethdev_init_telemetry)
"Returns module EEPROM info with SFF specs. Parameters: int port_id");
rte_telemetry_register_cmd("/ethdev/macs", eth_dev_handle_port_macs,
"Returns the MAC addresses for a port. Parameters: int port_id");
+ rte_telemetry_register_cmd("/ethdev/flow_ctrl", eth_dev_handle_port_flow_ctrl,
+ "Returns flow ctrl info for a port. Parameters: int port_id");
}
--
2.33.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v2 07/13] ethdev: support telemetry query Rx queue info
2023-06-07 7:41 ` [PATCH v2 00/13] " Jie Hai
` (5 preceding siblings ...)
2023-06-07 7:42 ` [PATCH v2 06/13] ethdev: support telemetry query flow ctrl info Jie Hai
@ 2023-06-07 7:42 ` Jie Hai
2023-06-07 7:42 ` [PATCH v2 08/13] ethdev: support telemetry query Tx " Jie Hai
` (6 subsequent siblings)
13 siblings, 0 replies; 36+ messages in thread
From: Jie Hai @ 2023-06-07 7:42 UTC (permalink / raw)
To: Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko; +Cc: dev, liudongdong3
This patch support querying information of Rx queues.
The command is like:
--> /ethdev/rx_queue,0,0
{
"/ethdev/rx_queue": {
"mempool_name": "mb_pool_0",
"socket_id": 0,
"host_threshold": 0,
"prefetch_threshold": 0,
"writeback_threshold": 0,
"free_threshold": 32,
"rx_drop_en": "on",
"deferred_start": "off",
"rx_nseg": 0,
"share_group": 0,
"share_qid": 0,
"offloads": [
"RSS_HASH"
],
"rx_nmempool": 0,
"scattered_rx": "off",
"queue_state": 1,
"nb_desc": 1024,
"rx_buf_size": 2048,
"avail_thresh": 0,
"burst_flags": 0,
"burst_mode": "Vector Neon"
}
}
Signed-off-by: Jie Hai <haijie1@huawei.com>
---
lib/ethdev/rte_ethdev_telemetry.c | 127 ++++++++++++++++++++++++++++++
1 file changed, 127 insertions(+)
diff --git a/lib/ethdev/rte_ethdev_telemetry.c b/lib/ethdev/rte_ethdev_telemetry.c
index 9847aa528f14..d1875dbe110e 100644
--- a/lib/ethdev/rte_ethdev_telemetry.c
+++ b/lib/ethdev/rte_ethdev_telemetry.c
@@ -450,6 +450,131 @@ eth_dev_handle_port_flow_ctrl(const char *cmd __rte_unused,
return 0;
}
+static int
+ethdev_parse_queue_params(const char *params, bool is_rx,
+ uint16_t *port_id, uint16_t *queue_id)
+{
+ struct rte_eth_dev *dev;
+ const char *qid_param;
+ uint16_t nb_queues;
+ char *end_param;
+ uint64_t qid;
+ int ret;
+
+ ret = eth_dev_parse_port_params(params, port_id, &end_param, true);
+ if (ret < 0)
+ return ret;
+
+ dev = &rte_eth_devices[*port_id];
+ nb_queues = is_rx ? dev->data->nb_rx_queues : dev->data->nb_tx_queues;
+ if (nb_queues == 1 && *end_param == '\0')
+ qid = 0;
+ else {
+ qid_param = strtok(end_param, ",");
+ if (!qid_param || strlen(qid_param) == 0 || !isdigit(*qid_param))
+ return -EINVAL;
+
+ qid = strtoul(qid_param, &end_param, 0);
+ }
+ if (*end_param != '\0')
+ RTE_ETHDEV_LOG(NOTICE,
+ "Extra parameters passed to ethdev telemetry command, ignoring\n");
+
+ if (qid >= UINT16_MAX)
+ return -EINVAL;
+
+ *queue_id = qid;
+ return 0;
+}
+
+static int
+eth_dev_add_burst_mode(uint16_t port_id, uint16_t queue_id,
+ bool is_rx, struct rte_tel_data *d)
+{
+ struct rte_eth_burst_mode mode;
+ int ret;
+
+ if (is_rx)
+ ret = rte_eth_rx_burst_mode_get(port_id, queue_id, &mode);
+ else
+ ret = rte_eth_tx_burst_mode_get(port_id, queue_id, &mode);
+
+ if (ret == -ENOTSUP)
+ return 0;
+
+ if (ret != 0) {
+ RTE_ETHDEV_LOG(ERR,
+ "Failed to get burst mode for port %u\n", port_id);
+ return ret;
+ }
+
+ rte_tel_data_add_dict_uint(d, "burst_flags", mode.flags);
+ rte_tel_data_add_dict_string(d, "burst_mode", mode.info);
+ return 0;
+}
+
+static int
+eth_dev_handle_port_rxq(const char *cmd __rte_unused,
+ const char *params,
+ struct rte_tel_data *d)
+{
+ struct rte_eth_thresh *rx_thresh;
+ struct rte_eth_rxconf *rxconf;
+ struct rte_eth_rxq_info qinfo;
+ struct rte_tel_data *offload;
+ uint16_t port_id, queue_id;
+ int ret;
+
+ ret = ethdev_parse_queue_params(params, true, &port_id, &queue_id);
+ if (ret != 0)
+ return ret;
+
+ ret = rte_eth_rx_queue_info_get(port_id, queue_id, &qinfo);
+ if (ret != 0)
+ return ret;
+
+ rte_tel_data_start_dict(d);
+ rte_tel_data_add_dict_string(d, "mempool_name", qinfo.mp->name);
+ rte_tel_data_add_dict_uint(d, "socket_id", qinfo.mp->socket_id);
+
+ rx_thresh = &qinfo.conf.rx_thresh;
+ rte_tel_data_add_dict_uint(d, "host_threshold", rx_thresh->hthresh);
+ rte_tel_data_add_dict_uint(d, "prefetch_threshold", rx_thresh->pthresh);
+ rte_tel_data_add_dict_uint(d, "writeback_threshold", rx_thresh->wthresh);
+
+ rxconf = &qinfo.conf;
+ rte_tel_data_add_dict_uint(d, "free_threshold", rxconf->rx_free_thresh);
+ rte_tel_data_add_dict_string(d, "rx_drop_en",
+ rxconf->rx_drop_en == 0 ? "off" : "on");
+ rte_tel_data_add_dict_string(d, "deferred_start",
+ rxconf->rx_deferred_start == 0 ? "off" : "on");
+ rte_tel_data_add_dict_uint(d, "rx_nseg", rxconf->rx_nseg);
+ rte_tel_data_add_dict_uint(d, "share_group", rxconf->share_group);
+ rte_tel_data_add_dict_uint(d, "share_qid", rxconf->share_qid);
+
+ offload = rte_tel_data_alloc();
+ if (offload == NULL)
+ return -ENOMEM;
+
+ eth_dev_parse_rx_offloads(rxconf->offloads, offload);
+ rte_tel_data_add_dict_container(d, "offloads", offload, 0);
+
+ rte_tel_data_add_dict_uint(d, "rx_nmempool", rxconf->rx_nmempool);
+
+ rte_tel_data_add_dict_string(d, "scattered_rx",
+ qinfo.scattered_rx == 0 ? "off" : "on");
+ rte_tel_data_add_dict_uint(d, "queue_state", qinfo.queue_state);
+ rte_tel_data_add_dict_uint(d, "nb_desc", qinfo.nb_desc);
+ rte_tel_data_add_dict_uint(d, "rx_buf_size", qinfo.rx_buf_size);
+ rte_tel_data_add_dict_uint(d, "avail_thresh", qinfo.avail_thresh);
+
+ ret = eth_dev_add_burst_mode(port_id, queue_id, true, d);
+ if (ret != 0)
+ rte_tel_data_free(offload);
+
+ return ret;
+}
+
RTE_INIT(ethdev_init_telemetry)
{
rte_telemetry_register_cmd("/ethdev/list", eth_dev_handle_port_list,
@@ -473,4 +598,6 @@ RTE_INIT(ethdev_init_telemetry)
"Returns the MAC addresses for a port. Parameters: int port_id");
rte_telemetry_register_cmd("/ethdev/flow_ctrl", eth_dev_handle_port_flow_ctrl,
"Returns flow ctrl info for a port. Parameters: int port_id");
+ rte_telemetry_register_cmd("/ethdev/rx_queue", eth_dev_handle_port_rxq,
+ "Returns Rx queue info for a port. Parameters: int port_id, int queue_id (Optional if only one queue)");
}
--
2.33.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v2 08/13] ethdev: support telemetry query Tx queue info
2023-06-07 7:41 ` [PATCH v2 00/13] " Jie Hai
` (6 preceding siblings ...)
2023-06-07 7:42 ` [PATCH v2 07/13] ethdev: support telemetry query Rx queue info Jie Hai
@ 2023-06-07 7:42 ` Jie Hai
2023-06-07 7:42 ` [PATCH v2 09/13] ethdev: add firmware version in telemetry info command Jie Hai
` (5 subsequent siblings)
13 siblings, 0 replies; 36+ messages in thread
From: Jie Hai @ 2023-06-07 7:42 UTC (permalink / raw)
To: Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko; +Cc: dev, liudongdong3
This patch support querying information of Tx queues.
The command is like:
--> /ethdev/tx_queue,0,0
{
"/ethdev/tx_queue": {
"host_threshold": 0,
"prefetch_threshold": 0,
"writeback_threshold": 0,
"rs_threshold": 32,
"free_threshold": 928,
"deferred_start": "off",
"offloads": [
"MBUF_FAST_FREE"
],
"queue_state": 1,
"nb_desc": 1024,
"burst_flags": 0,
"burst_mode": "Vector Neon"
}
}
Signed-off-by: Jie Hai <haijie1@huawei.com>
---
lib/ethdev/rte_ethdev_telemetry.c | 50 +++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/lib/ethdev/rte_ethdev_telemetry.c b/lib/ethdev/rte_ethdev_telemetry.c
index d1875dbe110e..f69bcedac86f 100644
--- a/lib/ethdev/rte_ethdev_telemetry.c
+++ b/lib/ethdev/rte_ethdev_telemetry.c
@@ -575,6 +575,54 @@ eth_dev_handle_port_rxq(const char *cmd __rte_unused,
return ret;
}
+static int
+eth_dev_handle_port_txq(const char *cmd __rte_unused,
+ const char *params,
+ struct rte_tel_data *d)
+{
+ struct rte_eth_thresh *tx_thresh;
+ struct rte_eth_txconf *txconf;
+ struct rte_eth_txq_info qinfo;
+ struct rte_tel_data *offload;
+ uint16_t port_id, queue_id;
+ int ret;
+
+ ret = ethdev_parse_queue_params(params, false, &port_id, &queue_id);
+ if (ret != 0)
+ return ret;
+
+ ret = rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo);
+ if (ret != 0)
+ return ret;
+
+ rte_tel_data_start_dict(d);
+ tx_thresh = &qinfo.conf.tx_thresh;
+ txconf = &qinfo.conf;
+ rte_tel_data_add_dict_uint(d, "host_threshold", tx_thresh->hthresh);
+ rte_tel_data_add_dict_uint(d, "prefetch_threshold", tx_thresh->pthresh);
+ rte_tel_data_add_dict_uint(d, "writeback_threshold", tx_thresh->wthresh);
+ rte_tel_data_add_dict_uint(d, "rs_threshold", txconf->tx_rs_thresh);
+ rte_tel_data_add_dict_uint(d, "free_threshold", txconf->tx_free_thresh);
+ rte_tel_data_add_dict_string(d, "deferred_start",
+ txconf->tx_deferred_start == 0 ? "off" : "on");
+
+ offload = rte_tel_data_alloc();
+ if (offload == NULL)
+ return -ENOMEM;
+
+ eth_dev_parse_tx_offloads(txconf->offloads, offload);
+ rte_tel_data_add_dict_container(d, "offloads", offload, 0);
+
+ rte_tel_data_add_dict_uint(d, "queue_state", qinfo.queue_state);
+ rte_tel_data_add_dict_uint(d, "nb_desc", qinfo.nb_desc);
+
+ ret = eth_dev_add_burst_mode(port_id, queue_id, false, d);
+ if (ret != 0)
+ rte_tel_data_free(offload);
+
+ return 0;
+}
+
RTE_INIT(ethdev_init_telemetry)
{
rte_telemetry_register_cmd("/ethdev/list", eth_dev_handle_port_list,
@@ -600,4 +648,6 @@ RTE_INIT(ethdev_init_telemetry)
"Returns flow ctrl info for a port. Parameters: int port_id");
rte_telemetry_register_cmd("/ethdev/rx_queue", eth_dev_handle_port_rxq,
"Returns Rx queue info for a port. Parameters: int port_id, int queue_id (Optional if only one queue)");
+ rte_telemetry_register_cmd("/ethdev/tx_queue", eth_dev_handle_port_txq,
+ "Returns Tx queue info for a port. Parameters: int port_id, int queue_id (Optional if only one queue)");
}
--
2.33.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v2 09/13] ethdev: add firmware version in telemetry info command
2023-06-07 7:41 ` [PATCH v2 00/13] " Jie Hai
` (7 preceding siblings ...)
2023-06-07 7:42 ` [PATCH v2 08/13] ethdev: support telemetry query Tx " Jie Hai
@ 2023-06-07 7:42 ` Jie Hai
2023-06-07 7:42 ` [PATCH v2 10/13] ethdev: support telemetry query DCB info Jie Hai
` (4 subsequent siblings)
13 siblings, 0 replies; 36+ messages in thread
From: Jie Hai @ 2023-06-07 7:42 UTC (permalink / raw)
To: Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko; +Cc: dev, liudongdong3
This patch adds firmware version in telemetry info command.
An example is like:
--> /ethdev/info,0
{
"/ethdev/info": {
"name": "0000:bd:00.0",
"fw_version": "1.20.0.17",
....
}
}
Signed-off-by: Jie Hai <haijie1@huawei.com>
---
lib/ethdev/rte_ethdev_telemetry.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/lib/ethdev/rte_ethdev_telemetry.c b/lib/ethdev/rte_ethdev_telemetry.c
index f69bcedac86f..930181e5324f 100644
--- a/lib/ethdev/rte_ethdev_telemetry.c
+++ b/lib/ethdev/rte_ethdev_telemetry.c
@@ -281,6 +281,7 @@ eth_dev_handle_port_info(const char *cmd __rte_unused,
{
struct rte_tel_data *rx_offload, *tx_offload;
struct rte_tel_data *rxq_state, *txq_state;
+ char fw_version[RTE_TEL_MAX_STRING_LEN];
char mac_addr[RTE_ETHER_ADDR_FMT_SIZE];
struct rte_eth_dev *eth_dev;
uint16_t port_id;
@@ -312,6 +313,11 @@ eth_dev_handle_port_info(const char *cmd __rte_unused,
rte_tel_data_start_dict(d);
rte_tel_data_add_dict_string(d, "name", eth_dev->data->name);
+
+ if (rte_eth_dev_fw_version_get(port_id, fw_version,
+ RTE_TEL_MAX_STRING_LEN) == 0)
+ rte_tel_data_add_dict_string(d, "fw_version", fw_version);
+
rte_tel_data_add_dict_int(d, "state", eth_dev->state);
rte_tel_data_add_dict_int(d, "nb_rx_queues",
eth_dev->data->nb_rx_queues);
--
2.33.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v2 10/13] ethdev: support telemetry query DCB info
2023-06-07 7:41 ` [PATCH v2 00/13] " Jie Hai
` (8 preceding siblings ...)
2023-06-07 7:42 ` [PATCH v2 09/13] ethdev: add firmware version in telemetry info command Jie Hai
@ 2023-06-07 7:42 ` Jie Hai
2023-06-07 7:42 ` [PATCH v2 11/13] ethdev: support telemetry query RSS info Jie Hai
` (3 subsequent siblings)
13 siblings, 0 replies; 36+ messages in thread
From: Jie Hai @ 2023-06-07 7:42 UTC (permalink / raw)
To: Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko; +Cc: dev, liudongdong3
This patch supports querying DCB info.
The command is like:
--> /ethdev/dcb,0
{
"/ethdev/dcb": {
"tc_num": 1,
"tc0": {
"priority": 0,
"bw_percent": "100%",
"rxq_base": 0,
"txq_base": 0,
"nb_rxq": 4,
"nb_txq": 4
}
}
}
Signed-off-by: Jie Hai <haijie1@huawei.com>
---
lib/ethdev/rte_ethdev_telemetry.c | 79 +++++++++++++++++++++++++++++++
1 file changed, 79 insertions(+)
diff --git a/lib/ethdev/rte_ethdev_telemetry.c b/lib/ethdev/rte_ethdev_telemetry.c
index 930181e5324f..d0d55993102b 100644
--- a/lib/ethdev/rte_ethdev_telemetry.c
+++ b/lib/ethdev/rte_ethdev_telemetry.c
@@ -629,6 +629,83 @@ eth_dev_handle_port_txq(const char *cmd __rte_unused,
return 0;
}
+static int
+eth_dev_add_dcb_tc(struct rte_eth_dcb_info *dcb_info, struct rte_tel_data *d)
+{
+ struct rte_tel_data *tcds[RTE_ETH_DCB_NUM_TCS] = {NULL};
+ struct rte_eth_dcb_tc_queue_mapping *tcq;
+ char bw_percent[RTE_TEL_MAX_STRING_LEN];
+ char name[RTE_TEL_MAX_STRING_LEN];
+ struct rte_tel_data *tcd;
+ uint32_t i;
+
+ for (i = 0; i < dcb_info->nb_tcs; i++) {
+ tcd = rte_tel_data_alloc();
+ if (tcd == NULL) {
+ while (i-- > 0)
+ rte_tel_data_free(tcds[i]);
+ return -ENOMEM;
+ }
+
+ tcds[i] = tcd;
+ rte_tel_data_start_dict(tcd);
+
+ rte_tel_data_add_dict_uint(tcd, "priority", dcb_info->prio_tc[i]);
+ snprintf(bw_percent, RTE_TEL_MAX_STRING_LEN,
+ "%u%%", dcb_info->tc_bws[i]);
+ rte_tel_data_add_dict_string(tcd, "bw_percent", bw_percent);
+
+ tcq = &dcb_info->tc_queue;
+ rte_tel_data_add_dict_uint(tcd, "rxq_base", tcq->tc_rxq[0][i].base);
+ rte_tel_data_add_dict_uint(tcd, "txq_base", tcq->tc_txq[0][i].base);
+ rte_tel_data_add_dict_uint(tcd, "nb_rxq", tcq->tc_rxq[0][i].nb_queue);
+ rte_tel_data_add_dict_uint(tcd, "nb_txq", tcq->tc_txq[0][i].nb_queue);
+
+ snprintf(name, RTE_TEL_MAX_STRING_LEN, "tc%u", i);
+ rte_tel_data_add_dict_container(d, name, tcd, 0);
+ }
+
+ return 0;
+}
+
+static int
+eth_dev_add_dcb_info(uint16_t port_id, struct rte_tel_data *d)
+{
+ struct rte_eth_dcb_info dcb_info;
+ int ret;
+
+ ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
+ if (ret != 0) {
+ RTE_ETHDEV_LOG(ERR,
+ "Failed to get dcb info, ret = %d\n", ret);
+ return ret;
+ }
+
+ rte_tel_data_start_dict(d);
+ rte_tel_data_add_dict_uint(d, "tc_num", dcb_info.nb_tcs);
+
+ if (dcb_info.nb_tcs > 0)
+ return eth_dev_add_dcb_tc(&dcb_info, d);
+
+ return 0;
+}
+
+static int
+eth_dev_handle_port_dcb(const char *cmd __rte_unused,
+ const char *params,
+ struct rte_tel_data *d)
+{
+ uint16_t port_id;
+ char *end_param;
+ int ret;
+
+ ret = eth_dev_parse_port_params(params, &port_id, &end_param, false);
+ if (ret < 0)
+ return ret;
+
+ return eth_dev_add_dcb_info(port_id, d);
+}
+
RTE_INIT(ethdev_init_telemetry)
{
rte_telemetry_register_cmd("/ethdev/list", eth_dev_handle_port_list,
@@ -656,4 +733,6 @@ RTE_INIT(ethdev_init_telemetry)
"Returns Rx queue info for a port. Parameters: int port_id, int queue_id (Optional if only one queue)");
rte_telemetry_register_cmd("/ethdev/tx_queue", eth_dev_handle_port_txq,
"Returns Tx queue info for a port. Parameters: int port_id, int queue_id (Optional if only one queue)");
+ rte_telemetry_register_cmd("/ethdev/dcb", eth_dev_handle_port_dcb,
+ "Returns DCB info for a port. Parameters: int port_id");
}
--
2.33.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v2 11/13] ethdev: support telemetry query RSS info
2023-06-07 7:41 ` [PATCH v2 00/13] " Jie Hai
` (9 preceding siblings ...)
2023-06-07 7:42 ` [PATCH v2 10/13] ethdev: support telemetry query DCB info Jie Hai
@ 2023-06-07 7:42 ` Jie Hai
2023-06-07 14:08 ` Ferruh Yigit
2023-06-07 7:42 ` [PATCH v2 12/13] ethdev: support telemetry query FEC info Jie Hai
` (2 subsequent siblings)
13 siblings, 1 reply; 36+ messages in thread
From: Jie Hai @ 2023-06-07 7:42 UTC (permalink / raw)
To: Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko; +Cc: dev, liudongdong3
This patch supports querying RSS info by telemetry command.
The command is like:
--> /ethdev/rss_info,0
{
"/ethdev/rss_info": {
"rss_hf": "0x238c",
"rss_key_len": 40,
"rss_key": "6d5a56da255b0ec24167253d43a38fb0d0ca2b\
cbae7b30b477cb2da38030f20c6a42b73bbeac01fa"
}
}
Signed-off-by: Jie Hai <haijie1@huawei.com>
---
lib/ethdev/rte_ethdev_telemetry.c | 79 +++++++++++++++++++++++++++++++
1 file changed, 79 insertions(+)
diff --git a/lib/ethdev/rte_ethdev_telemetry.c b/lib/ethdev/rte_ethdev_telemetry.c
index d0d55993102b..d42901fe57b1 100644
--- a/lib/ethdev/rte_ethdev_telemetry.c
+++ b/lib/ethdev/rte_ethdev_telemetry.c
@@ -706,6 +706,83 @@ eth_dev_handle_port_dcb(const char *cmd __rte_unused,
return eth_dev_add_dcb_info(port_id, d);
}
+static int
+eth_dev_add_rss_info(struct rte_eth_rss_conf *rss_conf, struct rte_tel_data *d)
+{
+ const uint32_t key_len = rss_conf->rss_key_len * 2 + 1;
+ char *rss_key;
+ char *key;
+ uint32_t i;
+ int ret;
+
+ key = malloc(key_len);
+ if (key == NULL)
+ return -ENOMEM;
+
+ rss_key = malloc(key_len);
+ if (rss_key == NULL) {
+ ret = -ENOMEM;
+ goto free_key;
+ }
+
+ rte_tel_data_start_dict(d);
+ rte_tel_data_add_dict_uint_hex(d, "rss_hf", rss_conf->rss_hf, 0);
+ rte_tel_data_add_dict_uint(d, "rss_key_len", rss_conf->rss_key_len);
+
+ memset(rss_key, 0, key_len);
+ for (i = 0; i < rss_conf->rss_key_len; i++) {
+ ret = snprintf(key, key_len, "%02x", rss_conf->rss_key[i]);
+ if (ret < 0)
+ goto free_rss_key;
+ strlcat(rss_key, key, key_len);
+ }
+ ret = rte_tel_data_add_dict_string(d, "rss_key", rss_key);
+
+free_rss_key:
+ free(rss_key);
+free_key:
+ free(key);
+ return ret;
+}
+
+static int
+eth_dev_handle_port_rss_info(const char *cmd __rte_unused,
+ const char *params,
+ struct rte_tel_data *d)
+{
+ struct rte_eth_dev_info dev_info;
+ struct rte_eth_rss_conf rss_conf;
+ uint16_t port_id;
+ char *end_param;
+ int ret;
+
+ ret = eth_dev_parse_port_params(params, &port_id, &end_param, false);
+ if (ret < 0)
+ return ret;
+
+ ret = rte_eth_dev_info_get(port_id, &dev_info);
+ if (ret != 0) {
+ RTE_ETHDEV_LOG(ERR,
+ "Failed to get device info, ret = %d\n", ret);
+ return ret;
+ }
+
+ rss_conf.rss_key_len = dev_info.hash_key_size;
+ rss_conf.rss_key = malloc(dev_info.hash_key_size);
+ if (rss_conf.rss_key == NULL)
+ return -ENOMEM;
+
+ ret = rte_eth_dev_rss_hash_conf_get(port_id, &rss_conf);
+ if (ret != 0) {
+ free(rss_conf.rss_key);
+ return ret;
+ }
+
+ ret = eth_dev_add_rss_info(&rss_conf, d);
+ free(rss_conf.rss_key);
+ return ret;
+}
+
RTE_INIT(ethdev_init_telemetry)
{
rte_telemetry_register_cmd("/ethdev/list", eth_dev_handle_port_list,
@@ -735,4 +812,6 @@ RTE_INIT(ethdev_init_telemetry)
"Returns Tx queue info for a port. Parameters: int port_id, int queue_id (Optional if only one queue)");
rte_telemetry_register_cmd("/ethdev/dcb", eth_dev_handle_port_dcb,
"Returns DCB info for a port. Parameters: int port_id");
+ rte_telemetry_register_cmd("/ethdev/rss_info", eth_dev_handle_port_rss_info,
+ "Returns RSS info for a port. Parameters: int port_id");
}
--
2.33.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v2 12/13] ethdev: support telemetry query FEC info
2023-06-07 7:41 ` [PATCH v2 00/13] " Jie Hai
` (10 preceding siblings ...)
2023-06-07 7:42 ` [PATCH v2 11/13] ethdev: support telemetry query RSS info Jie Hai
@ 2023-06-07 7:42 ` Jie Hai
2023-06-07 7:42 ` [PATCH v2 13/13] ethdev: support telemetry query VLAN info Jie Hai
2023-06-07 11:40 ` [PATCH v2 00/13] support telemetry query ethdev info Ferruh Yigit
13 siblings, 0 replies; 36+ messages in thread
From: Jie Hai @ 2023-06-07 7:42 UTC (permalink / raw)
To: Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko; +Cc: dev, liudongdong3
This patch supports getting FEC information by telemetry.
The command is like:
--> /ethdev/fec,0
{
"/ethdev/fec": {
"fec_mode": "off",
"fec_capability": {
"10_Gbps": "off auto baser"
}
}
}
Signed-off-by: Jie Hai <haijie1@huawei.com>
---
lib/ethdev/rte_ethdev_telemetry.c | 139 ++++++++++++++++++++++++++++++
1 file changed, 139 insertions(+)
diff --git a/lib/ethdev/rte_ethdev_telemetry.c b/lib/ethdev/rte_ethdev_telemetry.c
index d42901fe57b1..764cf8f203fb 100644
--- a/lib/ethdev/rte_ethdev_telemetry.c
+++ b/lib/ethdev/rte_ethdev_telemetry.c
@@ -11,6 +11,17 @@
#include "ethdev_driver.h"
#include "sff_telemetry.h"
+static const struct {
+ uint32_t capa;
+ const char *name;
+} rte_eth_fec_capa_name[] = {
+ { RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC), "off" },
+ { RTE_ETH_FEC_MODE_CAPA_MASK(AUTO), "auto" },
+ { RTE_ETH_FEC_MODE_CAPA_MASK(BASER), "baser" },
+ { RTE_ETH_FEC_MODE_CAPA_MASK(RS), "rs" },
+ { RTE_ETH_FEC_MODE_CAPA_MASK(LLRS), "llrs" },
+};
+
static int
eth_dev_parse_port_params(const char *params __rte_unused, uint16_t *port_id,
char **end_param, bool has_next)
@@ -783,6 +794,132 @@ eth_dev_handle_port_rss_info(const char *cmd __rte_unused,
return ret;
}
+static const char *
+eth_dev_fec_capa_to_string(uint32_t fec_capa)
+{
+ uint32_t i;
+
+ for (i = 0; i < RTE_DIM(rte_eth_fec_capa_name); i++) {
+ if ((fec_capa & rte_eth_fec_capa_name[i].capa) != 0)
+ return rte_eth_fec_capa_name[i].name;
+ }
+
+ return "unknown";
+}
+
+static void
+eth_dev_fec_capas_to_string(uint32_t fec_capa, char *fec_name, uint32_t len)
+{
+ bool valid = false;
+ size_t count = 0;
+ uint32_t i;
+
+ for (i = 0; i < RTE_DIM(rte_eth_fec_capa_name); i++) {
+ if ((fec_capa & rte_eth_fec_capa_name[i].capa) != 0) {
+ strlcat(fec_name, rte_eth_fec_capa_name[i].name, len);
+ count = strlcat(fec_name, " ", len);
+ valid = true;
+ }
+ }
+
+ if (!valid)
+ count = snprintf(fec_name, len, "unknown ");
+
+ if (count >= len) {
+ RTE_ETHDEV_LOG(WARNING, "FEC capa names may be truncated\n");
+ count = len;
+ }
+
+ fec_name[count - 1] = '\0';
+}
+
+static int
+eth_dev_get_fec_capability(uint16_t port_id, struct rte_tel_data *d)
+{
+ struct rte_eth_fec_capa *speed_fec_capa;
+ char fec_name[RTE_TEL_MAX_STRING_LEN];
+ char speed[RTE_TEL_MAX_STRING_LEN];
+ uint32_t capa_num;
+ uint32_t i, j;
+ int ret;
+
+ ret = rte_eth_fec_get_capability(port_id, NULL, 0);
+ if (ret <= 0)
+ return ret == 0 ? -EINVAL : ret;
+
+ capa_num = ret;
+ speed_fec_capa = calloc(capa_num, sizeof(struct rte_eth_fec_capa));
+ if (speed_fec_capa == NULL)
+ return -ENOMEM;
+
+ ret = rte_eth_fec_get_capability(port_id, speed_fec_capa, capa_num);
+ if (ret <= 0) {
+ ret = ret == 0 ? -EINVAL : ret;
+ goto out;
+ }
+
+ for (i = 0; i < capa_num; i++) {
+ memset(fec_name, 0, RTE_TEL_MAX_STRING_LEN);
+ eth_dev_fec_capas_to_string(speed_fec_capa[i].capa, fec_name,
+ RTE_TEL_MAX_STRING_LEN);
+
+ memset(speed, 0, RTE_TEL_MAX_STRING_LEN);
+ ret = snprintf(speed, RTE_TEL_MAX_STRING_LEN, "%s",
+ rte_eth_link_speed_to_str(speed_fec_capa[i].speed));
+ if (ret < 0)
+ goto out;
+
+ for (j = 0; j < strlen(speed); j++) {
+ if (speed[j] == ' ')
+ speed[j] = '_';
+ }
+
+ rte_tel_data_add_dict_string(d, speed, fec_name);
+ }
+
+out:
+ free(speed_fec_capa);
+ return ret > 0 ? 0 : ret;
+}
+
+static int
+eth_dev_handle_port_fec(const char *cmd __rte_unused,
+ const char *params,
+ struct rte_tel_data *d)
+{
+ struct rte_tel_data *fec_capas;
+ uint32_t fec_mode;
+ uint16_t port_id;
+ char *end_param;
+ int ret;
+
+ ret = eth_dev_parse_port_params(params, &port_id, &end_param, false);
+ if (ret < 0)
+ return ret;
+
+ ret = rte_eth_fec_get(port_id, &fec_mode);
+ if (ret != 0)
+ return ret;
+
+ rte_tel_data_start_dict(d);
+ rte_tel_data_add_dict_string(d, "fec_mode",
+ eth_dev_fec_capa_to_string(fec_mode));
+
+ fec_capas = rte_tel_data_alloc();
+ if (fec_capas == NULL)
+ return -ENOMEM;
+
+ rte_tel_data_start_dict(fec_capas);
+ ret = eth_dev_get_fec_capability(port_id, fec_capas);
+ if (ret != 0) {
+ rte_tel_data_free(fec_capas);
+ return ret;
+ }
+
+ rte_tel_data_add_dict_container(d, "fec_capability", fec_capas, 0);
+ return 0;
+}
+
RTE_INIT(ethdev_init_telemetry)
{
rte_telemetry_register_cmd("/ethdev/list", eth_dev_handle_port_list,
@@ -814,4 +951,6 @@ RTE_INIT(ethdev_init_telemetry)
"Returns DCB info for a port. Parameters: int port_id");
rte_telemetry_register_cmd("/ethdev/rss_info", eth_dev_handle_port_rss_info,
"Returns RSS info for a port. Parameters: int port_id");
+ rte_telemetry_register_cmd("/ethdev/fec", eth_dev_handle_port_fec,
+ "Returns FEC info for a port. Parameters: int port_id");
}
--
2.33.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v2 13/13] ethdev: support telemetry query VLAN info
2023-06-07 7:41 ` [PATCH v2 00/13] " Jie Hai
` (11 preceding siblings ...)
2023-06-07 7:42 ` [PATCH v2 12/13] ethdev: support telemetry query FEC info Jie Hai
@ 2023-06-07 7:42 ` Jie Hai
2023-06-07 11:40 ` [PATCH v2 00/13] support telemetry query ethdev info Ferruh Yigit
13 siblings, 0 replies; 36+ messages in thread
From: Jie Hai @ 2023-06-07 7:42 UTC (permalink / raw)
To: Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko; +Cc: dev, liudongdong3
This patch supports querying VLAN information by telemetry.
The command is like:
--> /ethdev/vlan,0
{
"/ethdev/vlan": {
"pvid": 0,
"hw_vlan_reject_tagged": 0,
"hw_vlan_reject_untagged": 0,
"hw_vlan_insert_pvid": 0,
"VLAN_STRIP": "off",
"VLAN_EXTEND": "off",
"QINQ_STRIP": "off",
"VLAN_FILTER": "on",
"vlan_num": 3,
"vlan_ids": {
"vlan_0_to_63": [
1,
20
],
"vlan_192_to_255": [
200
]
}
}
}
Signed-off-by: Jie Hai <haijie1@huawei.com>
---
lib/ethdev/rte_ethdev_telemetry.c | 107 ++++++++++++++++++++++++++++++
1 file changed, 107 insertions(+)
diff --git a/lib/ethdev/rte_ethdev_telemetry.c b/lib/ethdev/rte_ethdev_telemetry.c
index 764cf8f203fb..d11597596921 100644
--- a/lib/ethdev/rte_ethdev_telemetry.c
+++ b/lib/ethdev/rte_ethdev_telemetry.c
@@ -920,6 +920,111 @@ eth_dev_handle_port_fec(const char *cmd __rte_unused,
return 0;
}
+static int
+eth_dev_add_vlan_id(int port_id, struct rte_tel_data *d)
+{
+ struct rte_tel_data *vlan_blks[64] = {NULL};
+ uint16_t vlan_num, vidx, vbit, num_blks;
+ char blk_name[RTE_TEL_MAX_STRING_LEN];
+ struct rte_vlan_filter_conf *vfc;
+ struct rte_tel_data *vlan_blk;
+ struct rte_tel_data *vd;
+ uint64_t bit_width;
+ uint64_t vlan_id;
+
+ vd = rte_tel_data_alloc();
+ if (vd == NULL)
+ return -ENOMEM;
+
+ vfc = &rte_eth_devices[port_id].data->vlan_filter_conf;
+ bit_width = CHAR_BIT * sizeof(uint64_t);
+ vlan_num = 0;
+ num_blks = 0;
+
+ rte_tel_data_start_dict(vd);
+ for (vidx = 0; vidx < RTE_DIM(vfc->ids); vidx++) {
+ if (vfc->ids[vidx] == 0)
+ continue;
+
+ vlan_blk = rte_tel_data_alloc();
+ if (vlan_blk == NULL)
+ goto free_all;
+
+ vlan_blks[num_blks] = vlan_blk;
+ num_blks++;
+ snprintf(blk_name, RTE_TEL_MAX_STRING_LEN, "vlan_%"PRIu64"_to_%"PRIu64"",
+ bit_width * vidx, bit_width * (vidx + 1) - 1);
+ rte_tel_data_start_array(vlan_blk, RTE_TEL_UINT_VAL);
+ rte_tel_data_add_dict_container(vd, blk_name, vlan_blk, 0);
+
+ for (vbit = 0; vbit < bit_width; vbit++) {
+ if ((vfc->ids[vidx] & RTE_BIT64(vbit)) == 0)
+ continue;
+
+ vlan_id = bit_width * vidx + vbit;
+ rte_tel_data_add_array_uint(vlan_blk, vlan_id);
+ vlan_num++;
+ }
+ }
+
+ rte_tel_data_add_dict_uint(d, "vlan_num", vlan_num);
+ rte_tel_data_add_dict_container(d, "vlan_ids", vd, 0);
+
+ return 0;
+
+free_all:
+ while (num_blks-- > 0)
+ rte_tel_data_free(vlan_blks[num_blks]);
+
+ rte_tel_data_free(vd);
+ return -ENOMEM;
+}
+
+static int
+eth_dev_handle_port_vlan(const char *cmd __rte_unused,
+ const char *params,
+ struct rte_tel_data *d)
+{
+ struct rte_eth_txmode *txmode;
+ struct rte_eth_conf dev_conf;
+ uint16_t port_id;
+ int offload, ret;
+ char *end_param;
+
+ ret = eth_dev_parse_port_params(params, &port_id, &end_param, false);
+ if (ret < 0)
+ return ret;
+
+ ret = rte_eth_dev_conf_get(port_id, &dev_conf);
+ if (ret != 0) {
+ RTE_ETHDEV_LOG(ERR,
+ "Failed to get device configuration, ret = %d\n", ret);
+ return ret;
+ }
+
+ txmode = &dev_conf.txmode;
+ rte_tel_data_start_dict(d);
+ rte_tel_data_add_dict_uint(d, "pvid", txmode->pvid);
+ rte_tel_data_add_dict_uint(d, "hw_vlan_reject_tagged",
+ txmode->hw_vlan_reject_tagged);
+ rte_tel_data_add_dict_uint(d, "hw_vlan_reject_untagged",
+ txmode->hw_vlan_reject_untagged);
+ rte_tel_data_add_dict_uint(d, "hw_vlan_insert_pvid",
+ txmode->hw_vlan_insert_pvid);
+
+ offload = rte_eth_dev_get_vlan_offload(port_id);
+ rte_tel_data_add_dict_string(d, "VLAN_STRIP",
+ ((offload & RTE_ETH_VLAN_STRIP_OFFLOAD) != 0) ? "on" : "off");
+ rte_tel_data_add_dict_string(d, "VLAN_EXTEND",
+ ((offload & RTE_ETH_VLAN_EXTEND_OFFLOAD) != 0) ? "on" : "off");
+ rte_tel_data_add_dict_string(d, "QINQ_STRIP",
+ ((offload & RTE_ETH_QINQ_STRIP_OFFLOAD) != 0) ? "on" : "off");
+ rte_tel_data_add_dict_string(d, "VLAN_FILTER",
+ ((offload & RTE_ETH_VLAN_FILTER_OFFLOAD) != 0) ? "on" : "off");
+
+ return eth_dev_add_vlan_id(port_id, d);
+}
+
RTE_INIT(ethdev_init_telemetry)
{
rte_telemetry_register_cmd("/ethdev/list", eth_dev_handle_port_list,
@@ -953,4 +1058,6 @@ RTE_INIT(ethdev_init_telemetry)
"Returns RSS info for a port. Parameters: int port_id");
rte_telemetry_register_cmd("/ethdev/fec", eth_dev_handle_port_fec,
"Returns FEC info for a port. Parameters: int port_id");
+ rte_telemetry_register_cmd("/ethdev/vlan", eth_dev_handle_port_vlan,
+ "Returns VLAN info for a port. Parameters: int port_id");
}
--
2.33.0
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v2 01/13] ethdev: fix incorrect argument of calloc
2023-06-07 7:41 ` [PATCH v2 01/13] ethdev: fix incorrect argument of calloc Jie Hai
@ 2023-06-07 11:35 ` Ferruh Yigit
0 siblings, 0 replies; 36+ messages in thread
From: Ferruh Yigit @ 2023-06-07 11:35 UTC (permalink / raw)
To: Jie Hai, Thomas Monjalon, Andrew Rybchenko, Morten Brørup,
Chengwen Feng
Cc: dev, liudongdong3
On 6/7/2023 8:41 AM, Jie Hai wrote:
> The 'calloc' uses number as first argument, sizeof is generally wrong.
> This patch fixes it.
>
> Fixes: 8af559f94cef ("ethdev: support telemetry private dump")
> Cc: stable@dpdk.org
>
> Signed-off-by: Jie Hai <haijie1@huawei.com>
> ---
> lib/ethdev/rte_ethdev.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
> index d46e74504e64..503d500429c0 100644
> --- a/lib/ethdev/rte_ethdev.c
> +++ b/lib/ethdev/rte_ethdev.c
> @@ -6548,7 +6548,7 @@ eth_dev_handle_port_dump_priv(const char *cmd __rte_unused,
> if (!rte_eth_dev_is_valid_port(port_id))
> return -EINVAL;
>
> - buf = calloc(sizeof(char), RTE_TEL_MAX_SINGLE_STRING_LEN);
> + buf = calloc(RTE_TEL_MAX_SINGLE_STRING_LEN, sizeof(char));
> if (buf == NULL)
> return -ENOMEM;
>
Functionality should be same, but there is no harm to fix, hence:
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v2 02/13] ethdev: extract telemetry codes to a file
2023-06-07 7:41 ` [PATCH v2 02/13] ethdev: extract telemetry codes to a file Jie Hai
@ 2023-06-07 11:37 ` Ferruh Yigit
0 siblings, 0 replies; 36+ messages in thread
From: Ferruh Yigit @ 2023-06-07 11:37 UTC (permalink / raw)
To: Jie Hai, Thomas Monjalon, Andrew Rybchenko; +Cc: dev, liudongdong3
On 6/7/2023 8:41 AM, Jie Hai wrote:
> This patch extracts telemetry related codes in rte_ethdev.c
> to a new file rte_ethdev_telemetry.c.
>
> Signed-off-by: Jie Hai <haijie1@huawei.com>
<...>
> new file mode 100644
> index 000000000000..ec8e48877187
> --- /dev/null
> +++ b/lib/ethdev/rte_ethdev_telemetry.c
> @@ -0,0 +1,344 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2010-2017 Intel Corporation
> + */
>
Empty line after spdx tag
> +#include <ctype.h>
>
ctype.h can be removed from 'rte_ethdev.c' now
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v2 03/13] ethdev: extract codes parsing port ID as a function
2023-06-07 7:41 ` [PATCH v2 03/13] ethdev: extract codes parsing port ID as a function Jie Hai
@ 2023-06-07 11:37 ` Ferruh Yigit
0 siblings, 0 replies; 36+ messages in thread
From: Ferruh Yigit @ 2023-06-07 11:37 UTC (permalink / raw)
To: Jie Hai, Thomas Monjalon, Andrew Rybchenko; +Cc: dev, liudongdong3
On 6/7/2023 8:41 AM, Jie Hai wrote:
> This patch extracts codes parsing port_id as a function.
> The port id of 'int' or 'unsigned long' type passing as
> 'uint16_t' may cause truncation, fix it.
>
> Signed-off-by: Jie Hai <haijie1@huawei.com>
> ---
> lib/ethdev/rte_ethdev_telemetry.c | 95 ++++++++++++++++---------------
> lib/ethdev/sff_telemetry.c | 4 +-
> 2 files changed, 52 insertions(+), 47 deletions(-)
>
> diff --git a/lib/ethdev/rte_ethdev_telemetry.c b/lib/ethdev/rte_ethdev_telemetry.c
> index ec8e48877187..5e70d0c2a66a 100644
> --- a/lib/ethdev/rte_ethdev_telemetry.c
> +++ b/lib/ethdev/rte_ethdev_telemetry.c
> @@ -11,6 +11,29 @@
> #include "ethdev_driver.h"
> #include "sff_telemetry.h"
>
> +static int
> +eth_dev_parse_port_params(const char *params __rte_unused, uint16_t *port_id,
> + char **end_param, bool has_next)
>
'__rte_unused' is not required for 'params'
> +{
> + uint64_t pi;
> +
> + if (params == NULL || strlen(params) == 0 ||
> + !isdigit(*params) || port_id == NULL)
> + return -EINVAL;
> +
> + pi = strtoul(params, end_param, 0);
> + if (**end_param != '\0' && !has_next)
> + RTE_ETHDEV_LOG(NOTICE,
> + "Extra parameters passed to ethdev telemetry command, ignoring\n");
> +
> + if (pi >= UINT16_MAX || !rte_eth_dev_is_valid_port(pi))
> + return -EINVAL;
> +
> + *port_id = pi;
>
there is 64 -> 16 bit conversion, there is a "pi >= UINT16_MAX" check
already but not sure if all compilers get it, better to add explicit
cast for any case.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v2 00/13] support telemetry query ethdev info
2023-06-07 7:41 ` [PATCH v2 00/13] " Jie Hai
` (12 preceding siblings ...)
2023-06-07 7:42 ` [PATCH v2 13/13] ethdev: support telemetry query VLAN info Jie Hai
@ 2023-06-07 11:40 ` Ferruh Yigit
2023-06-08 2:01 ` Jie Hai
13 siblings, 1 reply; 36+ messages in thread
From: Ferruh Yigit @ 2023-06-07 11:40 UTC (permalink / raw)
To: Jie Hai; +Cc: dev, liudongdong3
On 6/7/2023 8:41 AM, Jie Hai wrote:
> This patchset supports querying information about ethdev.
> The information includes MAC addresses, RxTx offload, flow ctrl,
> Rx|Tx queue, firmware version, DCB, RSS, FEC, VLAN, etc.
>
> v1->v2:
> 1. Fix incorrect argument of calloc.
> 2. Extract telemetry codes to a file.
> 3. Extract codes parsing port id as a function.
> 4. Use malloc instead of rte_malloc.
> 5. Fix codecheck warnings and build errors reported by CI.
> 6. Use 'int' instead of 'unsigned' in help info.
>
> Dengdui Huang (1):
> ethdev: support telemetry query MAC addresses
>
> Jie Hai (12):
> ethdev: fix incorrect argument of calloc
> ethdev: extract telemetry codes to a file
> ethdev: extract codes parsing port ID as a function
> ethdev: support RxTx offload display
> ethdev: support telemetry query flow ctrl info
> ethdev: support telemetry query Rx queue info
> ethdev: support telemetry query Tx queue info
> ethdev: add firmware version in telemetry info command
> ethdev: support telemetry query DCB info
> ethdev: support telemetry query RSS info
> ethdev: support telemetry query FEC info
> ethdev: support telemetry query VLAN info
>
For series,
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
There are minor comments, applied them while merging set.
Series applied to dpdk-next-net/main, thanks.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v2 11/13] ethdev: support telemetry query RSS info
2023-06-07 7:42 ` [PATCH v2 11/13] ethdev: support telemetry query RSS info Jie Hai
@ 2023-06-07 14:08 ` Ferruh Yigit
0 siblings, 0 replies; 36+ messages in thread
From: Ferruh Yigit @ 2023-06-07 14:08 UTC (permalink / raw)
To: Jie Hai, Thomas Monjalon, Andrew Rybchenko; +Cc: dev, liudongdong3
On 6/7/2023 8:42 AM, Jie Hai wrote:
> This patch supports querying RSS info by telemetry command.
> The command is like:
> --> /ethdev/rss_info,0
> {
> "/ethdev/rss_info": {
> "rss_hf": "0x238c",
> "rss_key_len": 40,
> "rss_key": "6d5a56da255b0ec24167253d43a38fb0d0ca2b\
> cbae7b30b477cb2da38030f20c6a42b73bbeac01fa"
> }
> }
>
> Signed-off-by: Jie Hai <haijie1@huawei.com>
> ---
> lib/ethdev/rte_ethdev_telemetry.c | 79 +++++++++++++++++++++++++++++++
> 1 file changed, 79 insertions(+)
>
> diff --git a/lib/ethdev/rte_ethdev_telemetry.c b/lib/ethdev/rte_ethdev_telemetry.c
> index d0d55993102b..d42901fe57b1 100644
> --- a/lib/ethdev/rte_ethdev_telemetry.c
> +++ b/lib/ethdev/rte_ethdev_telemetry.c
> @@ -706,6 +706,83 @@ eth_dev_handle_port_dcb(const char *cmd __rte_unused,
> return eth_dev_add_dcb_info(port_id, d);
> }
>
> +static int
> +eth_dev_add_rss_info(struct rte_eth_rss_conf *rss_conf, struct rte_tel_data *d)
> +{
> + const uint32_t key_len = rss_conf->rss_key_len * 2 + 1;
> + char *rss_key;
> + char *key;
> + uint32_t i;
> + int ret;
> +
> + key = malloc(key_len);
> + if (key == NULL)
> + return -ENOMEM;
> +
Key is to hold only char representation of single byte, so it doesn't
need this much space and no need to dynamically allocate/free small
space, hence updating in next-net as following:
```
diff --git a/lib/ethdev/rte_ethdev_telemetry.c
b/lib/ethdev/rte_ethdev_telemetry.c
index c64045cb1dad..f246a03e2966 100644
--- a/lib/ethdev/rte_ethdev_telemetry.c
+++ b/lib/ethdev/rte_ethdev_telemetry.c
@@ -723,19 +723,13 @@ eth_dev_add_rss_info(struct rte_eth_rss_conf
*rss_conf, struct rte_tel_data *d)
{
const uint32_t key_len = rss_conf->rss_key_len * 2 + 1;
char *rss_key;
- char *key;
+ char key[3]; /* FF\0 */
uint32_t i;
int ret;
- key = malloc(key_len);
- if (key == NULL)
- return -ENOMEM;
-
rss_key = malloc(key_len);
- if (rss_key == NULL) {
- ret = -ENOMEM;
- goto free_key;
- }
+ if (rss_key == NULL)
+ return -ENOMEM;
rte_tel_data_start_dict(d);
rte_tel_data_add_dict_uint_hex(d, "rss_hf", rss_conf->rss_hf, 0);
@@ -743,7 +737,7 @@ eth_dev_add_rss_info(struct rte_eth_rss_conf
*rss_conf, struct rte_tel_data *d)
memset(rss_key, 0, key_len);
for (i = 0; i < rss_conf->rss_key_len; i++) {
- ret = snprintf(key, key_len, "%02x",
rss_conf->rss_key[i]);
+ ret = snprintf(key, 3, "%02x", rss_conf->rss_key[i]);
if (ret < 0)
goto free_rss_key;
strlcat(rss_key, key, key_len);
@@ -752,8 +746,7 @@ eth_dev_add_rss_info(struct rte_eth_rss_conf
*rss_conf, struct rte_tel_data *d)
free_rss_key:
free(rss_key);
-free_key:
- free(key);
+
return ret;
}
```
> + rss_key = malloc(key_len);
> + if (rss_key == NULL) {
> + ret = -ENOMEM;
> + goto free_key;
> + }
> +
> + rte_tel_data_start_dict(d);
> + rte_tel_data_add_dict_uint_hex(d, "rss_hf", rss_conf->rss_hf, 0);
> + rte_tel_data_add_dict_uint(d, "rss_key_len", rss_conf->rss_key_len);
> +
> + memset(rss_key, 0, key_len);
> + for (i = 0; i < rss_conf->rss_key_len; i++) {
> + ret = snprintf(key, key_len, "%02x", rss_conf->rss_key[i]);
> + if (ret < 0)
> + goto free_rss_key;
> + strlcat(rss_key, key, key_len);
> + }
> + ret = rte_tel_data_add_dict_string(d, "rss_key", rss_key);
> +
> +free_rss_key:
> + free(rss_key);
> +free_key:
> + free(key);
> + return ret;
> +}
> +
> +static int
> +eth_dev_handle_port_rss_info(const char *cmd __rte_unused,
> + const char *params,
> + struct rte_tel_data *d)
> +{
> + struct rte_eth_dev_info dev_info;
> + struct rte_eth_rss_conf rss_conf;
> + uint16_t port_id;
> + char *end_param;
> + int ret;
> +
> + ret = eth_dev_parse_port_params(params, &port_id, &end_param, false);
> + if (ret < 0)
> + return ret;
> +
> + ret = rte_eth_dev_info_get(port_id, &dev_info);
> + if (ret != 0) {
> + RTE_ETHDEV_LOG(ERR,
> + "Failed to get device info, ret = %d\n", ret);
> + return ret;
> + }
> +
> + rss_conf.rss_key_len = dev_info.hash_key_size;
> + rss_conf.rss_key = malloc(dev_info.hash_key_size);
> + if (rss_conf.rss_key == NULL)
> + return -ENOMEM;
> +
This patch cause telemetry unit test failure, because some pmd's provide
'0' as 'dev_info.hash_key_size', hence updating as following which sets
key size as 40 if 'dev_info.hash_key_size' is 0:
```
@@ -764,6 +757,7 @@ eth_dev_handle_port_rss_info(const char *cmd
__rte_unused,
{
struct rte_eth_dev_info dev_info;
struct rte_eth_rss_conf rss_conf;
+ uint8_t key_len;
uint16_t port_id;
char *end_param;
int ret;
@@ -779,8 +773,9 @@ eth_dev_handle_port_rss_info(const char *cmd
__rte_unused,
return ret;
}
- rss_conf.rss_key_len = dev_info.hash_key_size;
- rss_conf.rss_key = malloc(dev_info.hash_key_size);
+ key_len = dev_info.hash_key_size ? dev_info.hash_key_size : 40;
+ rss_conf.rss_key_len = key_len;
+ rss_conf.rss_key = malloc(key_len);
if (rss_conf.rss_key == NULL)
return -ENOMEM;
```
> + ret = rte_eth_dev_rss_hash_conf_get(port_id, &rss_conf);
> + if (ret != 0) {
> + free(rss_conf.rss_key);
> + return ret;
> + }
> +
> + ret = eth_dev_add_rss_info(&rss_conf, d);
> + free(rss_conf.rss_key);
> + return ret;
> +}
> +
> RTE_INIT(ethdev_init_telemetry)
> {
> rte_telemetry_register_cmd("/ethdev/list", eth_dev_handle_port_list,
> @@ -735,4 +812,6 @@ RTE_INIT(ethdev_init_telemetry)
> "Returns Tx queue info for a port. Parameters: int port_id, int queue_id (Optional if only one queue)");
> rte_telemetry_register_cmd("/ethdev/dcb", eth_dev_handle_port_dcb,
> "Returns DCB info for a port. Parameters: int port_id");
> + rte_telemetry_register_cmd("/ethdev/rss_info", eth_dev_handle_port_rss_info,
> + "Returns RSS info for a port. Parameters: int port_id");
> }
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [PATCH v2 00/13] support telemetry query ethdev info
2023-06-07 11:40 ` [PATCH v2 00/13] support telemetry query ethdev info Ferruh Yigit
@ 2023-06-08 2:01 ` Jie Hai
0 siblings, 0 replies; 36+ messages in thread
From: Jie Hai @ 2023-06-08 2:01 UTC (permalink / raw)
To: Ferruh Yigit; +Cc: dev, liudongdong3
On 2023/6/7 19:40, Ferruh Yigit wrote:
> On 6/7/2023 8:41 AM, Jie Hai wrote:
>> This patchset supports querying information about ethdev.
>> The information includes MAC addresses, RxTx offload, flow ctrl,
>> Rx|Tx queue, firmware version, DCB, RSS, FEC, VLAN, etc.
>>
>> v1->v2:
>> 1. Fix incorrect argument of calloc.
>> 2. Extract telemetry codes to a file.
>> 3. Extract codes parsing port id as a function.
>> 4. Use malloc instead of rte_malloc.
>> 5. Fix codecheck warnings and build errors reported by CI.
>> 6. Use 'int' instead of 'unsigned' in help info.
>>
>> Dengdui Huang (1):
>> ethdev: support telemetry query MAC addresses
>>
>> Jie Hai (12):
>> ethdev: fix incorrect argument of calloc
>> ethdev: extract telemetry codes to a file
>> ethdev: extract codes parsing port ID as a function
>> ethdev: support RxTx offload display
>> ethdev: support telemetry query flow ctrl info
>> ethdev: support telemetry query Rx queue info
>> ethdev: support telemetry query Tx queue info
>> ethdev: add firmware version in telemetry info command
>> ethdev: support telemetry query DCB info
>> ethdev: support telemetry query RSS info
>> ethdev: support telemetry query FEC info
>> ethdev: support telemetry query VLAN info
>>
>
> For series,
> Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
>
>
> There are minor comments, applied them while merging set.
>
> Series applied to dpdk-next-net/main, thanks.
> .
Hi Ferruh
Thank you for your valuable comments on the entire patch group.
Thanks,
Jie Hai
^ permalink raw reply [flat|nested] 36+ messages in thread
end of thread, other threads:[~2023-06-08 2:01 UTC | newest]
Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-30 9:05 [PATCH 00/10] support telemetry query ethdev info Jie Hai
2023-05-30 9:05 ` [PATCH 01/10] ethdev: support telemetry query MAC addresses Jie Hai
2023-06-01 14:39 ` Ferruh Yigit
2023-05-30 9:05 ` [PATCH 02/10] ethdev: support RxTx offload display Jie Hai
2023-05-30 9:05 ` [PATCH 03/10] ethdev: support telemetry query flow ctrl info Jie Hai
2023-05-30 9:05 ` [PATCH 04/10] ethdev: support telemetry query Rx queue info Jie Hai
2023-05-30 9:05 ` [PATCH 05/10] ethdev: support telemetry query Tx " Jie Hai
2023-05-30 9:05 ` [PATCH 06/10] ethdev: add firmware version in telemetry info command Jie Hai
2023-05-30 9:05 ` [PATCH 07/10] ethdev: support telemetry query DCB info Jie Hai
2023-05-30 9:05 ` [PATCH 08/10] ethdev: support telemetry query RSS info Jie Hai
2023-05-30 9:05 ` [PATCH 09/10] ethdev: support telemetry query FEC info Jie Hai
2023-05-30 9:05 ` [PATCH 10/10] ethdev: support telemetry query VLAN info Jie Hai
2023-06-01 12:05 ` [PATCH 00/10] support telemetry query ethdev info Ferruh Yigit
2023-06-01 12:23 ` Jie Hai
2023-06-01 14:36 ` Ferruh Yigit
2023-06-05 6:19 ` Jie Hai
2023-06-07 7:41 ` [PATCH v2 00/13] " Jie Hai
2023-06-07 7:41 ` [PATCH v2 01/13] ethdev: fix incorrect argument of calloc Jie Hai
2023-06-07 11:35 ` Ferruh Yigit
2023-06-07 7:41 ` [PATCH v2 02/13] ethdev: extract telemetry codes to a file Jie Hai
2023-06-07 11:37 ` Ferruh Yigit
2023-06-07 7:41 ` [PATCH v2 03/13] ethdev: extract codes parsing port ID as a function Jie Hai
2023-06-07 11:37 ` Ferruh Yigit
2023-06-07 7:41 ` [PATCH v2 04/13] ethdev: support telemetry query MAC addresses Jie Hai
2023-06-07 7:42 ` [PATCH v2 05/13] ethdev: support RxTx offload display Jie Hai
2023-06-07 7:42 ` [PATCH v2 06/13] ethdev: support telemetry query flow ctrl info Jie Hai
2023-06-07 7:42 ` [PATCH v2 07/13] ethdev: support telemetry query Rx queue info Jie Hai
2023-06-07 7:42 ` [PATCH v2 08/13] ethdev: support telemetry query Tx " Jie Hai
2023-06-07 7:42 ` [PATCH v2 09/13] ethdev: add firmware version in telemetry info command Jie Hai
2023-06-07 7:42 ` [PATCH v2 10/13] ethdev: support telemetry query DCB info Jie Hai
2023-06-07 7:42 ` [PATCH v2 11/13] ethdev: support telemetry query RSS info Jie Hai
2023-06-07 14:08 ` Ferruh Yigit
2023-06-07 7:42 ` [PATCH v2 12/13] ethdev: support telemetry query FEC info Jie Hai
2023-06-07 7:42 ` [PATCH v2 13/13] ethdev: support telemetry query VLAN info Jie Hai
2023-06-07 11:40 ` [PATCH v2 00/13] support telemetry query ethdev info Ferruh Yigit
2023-06-08 2:01 ` Jie Hai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).