fix queue stats mapping
RFC 2/2 app/testpmd: fix starting failed with queue-stats-mapping
In reply to Min Hu (Connor)From: Huisong Li <[email protected]>
testpmd fails to start with "--rx-queue-stats-mapping" and "--tx-queue-stats-mapping", which is caused by the failure and exit of 'map_port_queue_stats_mapping_registers' function. By default, the configuration of queue statistics mapping in the initialization process is implemented in the 'init_port_config' function. However, the dev_configure interface is not called to configure the NIC and dev->data-nb_rx/tx_queues is zero. As a result, 'rte_eth_dev_set_tx/rx_queue_stats_mapping' function fails to verify the queue_id. Therefore, it is necessary to move 'map_port_queue_stats_mapping_registers' from 'init_port_config' to 'start_port' function.
--- app/test-pmd/testpmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
app/test-pmd/testpmd.c +1 -1
@@ -2742,6 +2742,7 @@ start_port(portid_t pid) need_check_link_status =1 ; pl[cfg_pi++] = pi; +map_port_queue_stats_mapping_registers (pi, port); }if (need_check_link_status ==1 && !no_link_check)
@@ -3600,7 +3601,6 @@ init_port_config(void)if (ret !=0 )return ; -map_port_queue_stats_mapping_registers (pid, port);#if definedRTE_LIBRTE_IXGBE_PMD && definedRTE_LIBRTE_IXGBE_BYPASS rte_pmd_ixgbe_bypass_init (pid);#endif
Signature · 1 line
2.7.4
cover fix queue stats mapping
From: Huisong Li <[email protected]>
This patch set is used to adjust the unreasonable configurations
and runtime errors about rx/tx queue stats mapping.
Huisong Li (2):
app/testpmd: fix queue stats mapping configuration app/testpmd: fix starting failed with queue-stats-mapping
app/test-pmd/config.c | 180 ++++++++++++++++++++++++++++----------------- app/test-pmd/parameters.c | 63 ++++++++-------- app/test-pmd/testpmd.c | 182 ++++++++++++++++++++++++++++++++-------------- app/test-pmd/testpmd.h | 41 +++++------ 4 files changed, 293 insertions(+), 173 deletions(-)
Signature · 1 line
2.7.4
RFC 1/2 app/testpmd: fix queue stats mapping configuration
From: Huisong Li <[email protected]>
Currently, the queue stats mapping has the following problems:
1) Many PMD drivers don't support queue stats mapping. But there is no failure message after executing the command "set stat_qmap rx 0 2 2".
2) Once queue mapping is set, unrelated and unmapped queues are also displayed.
3) There is no need to keep cache line alignment for
'struct queue_stats_mappings'.
4) The mapping arrays, 'tx_queue_stats_mappings_array' & 'rx_queue_stats_mappings_array' are global and their sizes are based on fixed max port and queue size assumptions.
5) The configuration result does not take effect or can not be queried in real time.
Therefore, we have made the following adjustments:
1) If PMD supports queue stats mapping, configure to driver in real time after executing the command "set stat_qmap rx/tx ...". If not, the command can not be accepted.
2) Only display queues that mapping done by adding a new 'active' field in queue_stats_mappings struct.
3) Remove cache alignment for 'struct queue_stats_mappings'.
4) Add a new port_stats_mappings struct in rte_port.
The struct contains number of rx/txq stats mapping, rx/tx queue_stats_mapping_enabled flag, and rx/tx queue_stats_maping array. Size of queue_stats_mapping_array is set to "RTE_ETHDEV_QUEUE_STAT_CNTRS"
to ensure that the same number of queues can be set for each port.
--- app/test-pmd/config.c | 180 +++++++++++++++++++++++++++++----------------- app/test-pmd/parameters.c | 63 ++++++++-------- app/test-pmd/testpmd.c | 180 ++++++++++++++++++++++++++++++++-------------- app/test-pmd/testpmd.h | 41 ++++++----- 4 files changed, 292 insertions(+), 172 deletions(-)
app/test-pmd/config.c +115 -65
@@ -177,13 +177,13 @@ nic_stats_display(portid_t port_id)static uint64_t prev_bytes_rx[RTE_MAX_ETHPORTS ];static uint64_t prev_bytes_tx[RTE_MAX_ETHPORTS ];static uint64_t prev_ns[RTE_MAX_ETHPORTS ]; +struct port_stats_mappings *p_stats_map;struct timespec cur_time;uint64_t diff_pkts_rx, diff_pkts_tx, diff_bytes_rx, diff_bytes_tx, diff_ns;uint64_t mpps_rx, mpps_tx, mbps_rx, mbps_tx;struct rte_eth_stats stats; -struct rte_port *port = &ports[port_id]; -uint8_t i; +struct rte_port *port;static const char *nic_stats_border ="########################" ;
@@ -195,7 +195,10 @@ nic_stats_display(portid_t port_id)printf ("\n %s NIC statistics for port %-2d %s\n" , nic_stats_border, port_id, nic_stats_border); -if ((!port->rx_queue_stats_mapping_enabled) && (!port->tx_queue_stats_mapping_enabled)) { + port = &ports[port_id]; + p_stats_map = &port->p_stats_map; +if ((!p_stats_map->rx_queue_stats_mapping_enabled) && + (!p_stats_map->tx_queue_stats_mapping_enabled)) {printf (" RX-packets: %-10" PRIu64" RX-missed: %-10" PRIu64" RX-bytes: " "%-" PRIu64"\n" , stats.ipackets, stats.imissed, stats.ibytes);
@@ -205,36 +208,20 @@ nic_stats_display(portid_t port_id)printf (" TX-packets: %-10" PRIu64" TX-errors: %-10" PRIu64" TX-bytes: " "%-" PRIu64"\n" , stats.opackets, stats.oerrors, stats.obytes); - } -else { -printf (" RX-packets: %10" PRIu64" RX-errors: %10" PRIu64 -" RX-bytes: %10" PRIu64"\n" , - stats.ipackets, stats.ierrors, stats.ibytes); -printf (" RX-errors: %10" PRIu64"\n" , stats.ierrors); -printf (" RX-nombuf: %10" PRIu64"\n" , + }else { +printf (" RX-packets: %14" PRIu64" RX-missed: " +"%14" PRIu64" RX-bytes: %14" PRIu64"\n" , + stats.ipackets, stats.imissed, stats.ibytes); +printf (" RX-errors: %14" PRIu64"\n" , + stats.ierrors); +printf (" RX-nombuf: %14" PRIu64"\n" , stats.rx_nombuf); -printf (" TX-packets: %10" PRIu64" TX-errors: %10" PRIu64 -" TX-bytes: %10" PRIu64"\n" , +printf (" TX-packets: %14" PRIu64" TX-errors: " +"%14" PRIu64" TX-bytes: %14" PRIu64"\n" , stats.opackets, stats.oerrors, stats.obytes); } -if (port->rx_queue_stats_mapping_enabled) { -printf ("\n" ); -for (i =0 ; i <RTE_ETHDEV_QUEUE_STAT_CNTRS ; i++) { -printf (" Stats reg %2d RX-packets: %10" PRIu64 -" RX-errors: %10" PRIu64 -" RX-bytes: %10" PRIu64"\n" , - i, stats.q_ipackets[i], stats.q_errors[i], stats.q_ibytes[i]); - } - } -if (port->tx_queue_stats_mapping_enabled) { -printf ("\n" ); -for (i =0 ; i <RTE_ETHDEV_QUEUE_STAT_CNTRS ; i++) { -printf (" Stats reg %2d TX-packets: %10" PRIu64 -" TX-bytes: %10" PRIu64"\n" , - i, stats.q_opackets[i], stats.q_obytes[i]); - } - } +port_stats_mapping_display (port_id, &stats); diff_ns =0 ;if (clock_gettime (CLOCK_TYPE_ID , &cur_time) ==0 ) {
@@ -400,7 +387,9 @@ nic_xstats_clear(portid_t port_id)void nic_stats_mapping_display (portid_t port_id) { -struct rte_port *port = &ports[port_id]; +struct port_stats_mappings *p_stats_map; +struct queue_stats_mappings *q_stats_map; +struct rte_port *port;uint16_t i;static const char *nic_stats_mapping_border ="########################" ;
@@ -410,7 +399,10 @@ nic_stats_mapping_display(portid_t port_id)return ; } -if ((!port->rx_queue_stats_mapping_enabled) && (!port->tx_queue_stats_mapping_enabled)) { + port = &ports[port_id]; + p_stats_map = &port->p_stats_map; +if ((!p_stats_map->rx_queue_stats_mapping_enabled) && + (!p_stats_map->tx_queue_stats_mapping_enabled)) {printf ("Port id %d - either does not support queue statistic mapping or" " no queue statistic mapping set\n" , port_id);return ;
@@ -419,24 +411,26 @@ nic_stats_mapping_display(portid_t port_id)printf ("\n %s NIC statistics mapping for port %-2d %s\n" , nic_stats_mapping_border, port_id, nic_stats_mapping_border); -if (port->rx_queue_stats_mapping_enabled) { -for (i =0 ; i < nb_rx_queue_stats_mappings; i++) { -if (rx_queue_stats_mappings[i].port_id == port_id) { +if (p_stats_map->rx_queue_stats_mapping_enabled) { +for (i =0 ; i < p_stats_map->nb_rxq_stats_mappings; i++) { + q_stats_map = &p_stats_map->rxq_map_array[i]; +if (q_stats_map->active) {printf (" RX-queue %2d mapped to Stats Reg %2d\n" , - rx_queue_stats_mappings[i].queue_id, - rx_queue_stats_mappings[i].stats_counter_id); + q_stats_map->queue_id, + q_stats_map->stats_counter_id); } }printf ("\n" ); } -if (port->tx_queue_stats_mapping_enabled) { -for (i =0 ; i < nb_tx_queue_stats_mappings; i++) { -if (tx_queue_stats_mappings[i].port_id == port_id) { +if (p_stats_map->tx_queue_stats_mapping_enabled) { +for (i =0 ; i < p_stats_map->nb_txq_stats_mappings; i++) { + q_stats_map = &p_stats_map->txq_map_array[i]; +if (q_stats_map->active) {printf (" TX-queue %2d mapped to Stats Reg %2d\n" , - tx_queue_stats_mappings[i].queue_id, - tx_queue_stats_mappings[i].stats_counter_id); + q_stats_map->queue_id, + q_stats_map->stats_counter_id); } } }
@@ -4546,8 +4540,13 @@ tx_vlan_pvid_set(portid_t port_id, uint16_t vlan_id, int on)void set_qmap (portid_t port_id,uint8_t is_rx,uint16_t queue_id,uint8_t map_value) { +struct port_stats_mappings *p_stats_map; +struct queue_stats_mappings *q_stats_map; +bool existing_mapping_found = false; +struct rte_port *port; +uint16_t cur_map_idx;uint16_t i; -uint8_t existing_mapping_found =0 ; +int ret;if (port_id_is_invalid (port_id,ENABLED_WARN ))return ;
@@ -4561,37 +4560,88 @@ set_qmap(portid_t port_id, uint8_t is_rx, uint16_t queue_id, uint8_t map_value)return ; } -if (!is_rx) {/*then tx*/ -for (i =0 ; i < nb_tx_queue_stats_mappings; i++) { -if ((tx_queue_stats_mappings[i].port_id == port_id) && - (tx_queue_stats_mappings[i].queue_id == queue_id)) { - tx_queue_stats_mappings[i].stats_counter_id = map_value; - existing_mapping_found =1 ; + port = &ports[port_id]; + p_stats_map = &port->p_stats_map; +if (!is_rx) {/* tx */ +for (i =0 ; i < p_stats_map->nb_txq_stats_mappings; i++) { + q_stats_map = &p_stats_map->txq_map_array[i]; +if (q_stats_map->queue_id == queue_id) { + ret = +rte_eth_dev_set_tx_queue_stats_mapping (port_id, + queue_id, map_value); +if (ret) { +printf ("failed to set tx queue stats " +"mapping.\n" ); +return ; + } + + q_stats_map->stats_counter_id = map_value; + q_stats_map->active = true; + existing_mapping_found = true;break ; } } -if (!existing_mapping_found) {/* A new additional mapping... */ - tx_queue_stats_mappings[nb_tx_queue_stats_mappings].port_id = port_id; - tx_queue_stats_mappings[nb_tx_queue_stats_mappings].queue_id = queue_id; - tx_queue_stats_mappings[nb_tx_queue_stats_mappings].stats_counter_id = map_value; - nb_tx_queue_stats_mappings++; + +/* A new additional mapping... */ +if (!existing_mapping_found) { + ret =rte_eth_dev_set_tx_queue_stats_mapping (port_id, + queue_id, + map_value); +if (ret) { +printf ("failed to set tx queue stats " +"mapping.\n" ); +return ; + } + + cur_map_idx = p_stats_map->nb_txq_stats_mappings; + q_stats_map = &p_stats_map->txq_map_array[cur_map_idx]; + q_stats_map->queue_id = queue_id; + q_stats_map->stats_counter_id = map_value; + q_stats_map->active = true; + p_stats_map->nb_txq_stats_mappings++; } - } -else {/*rx*/ -for (i =0 ; i < nb_rx_queue_stats_mappings; i++) { -if ((rx_queue_stats_mappings[i].port_id == port_id) && - (rx_queue_stats_mappings[i].queue_id == queue_id)) { - rx_queue_stats_mappings[i].stats_counter_id = map_value; - existing_mapping_found =1 ; + + p_stats_map->tx_queue_stats_mapping_enabled = true; + }else {/* rx */ +for (i =0 ; i < p_stats_map->nb_rxq_stats_mappings; i++) { + q_stats_map = &p_stats_map->rxq_map_array[i]; +if (q_stats_map->queue_id == queue_id) { + ret = +rte_eth_dev_set_rx_queue_stats_mapping (port_id, + queue_id, map_value); +if (ret) { +printf ("failed to set rx queue stats " +"mapping.\n" ); +return ; + } + + q_stats_map->stats_counter_id = map_value; + q_stats_map->active = true; + existing_mapping_found = true;break ; } } -if (!existing_mapping_found) {/* A new additional mapping... */ - rx_queue_stats_mappings[nb_rx_queue_stats_mappings].port_id = port_id; - rx_queue_stats_mappings[nb_rx_queue_stats_mappings].queue_id = queue_id; - rx_queue_stats_mappings[nb_rx_queue_stats_mappings].stats_counter_id = map_value; - nb_rx_queue_stats_mappings++; + +/* A new additional mapping... */ +if (!existing_mapping_found) { + ret =rte_eth_dev_set_rx_queue_stats_mapping (port_id, + queue_id, + map_value); +if (ret) { +printf ("failed to set rx queue stats " +"mapping.\n" ); +return ; + } + + cur_map_idx = p_stats_map->nb_rxq_stats_mappings; + q_stats_map = &p_stats_map->rxq_map_array[cur_map_idx]; + q_stats_map->queue_id = queue_id; + q_stats_map->stats_counter_id = map_value; + q_stats_map->active = true; + p_stats_map->nb_rxq_stats_mappings++; } + + p_stats_map->rx_queue_stats_mapping_enabled = true; } }
app/test-pmd/parameters.c +30 -33
92 lines not on this page · raw message
app/test-pmd/testpmd.c +127 -53
261 lines not on this page · raw message
app/test-pmd/testpmd.h +20 -21
65 lines not on this page · raw message
Signature · 1 line
2.7.4