There is about 3% perf drop. And it is because of a bitrate
calculation in the datapath. So improve it by maintaining an array
of port indexes in testpmd, which is updated with ethdev events.
Fixes:
8728ccf37615 ("fix ethdev ports enumeration")
Cc: stable@dpdk.org
Signed-off-by: Xiaoyun Li <xiaoyun.li@intel.com>
Acked-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
struct fwd_lcore **fwd_lcores; /**< For all probed logical cores. */
lcoreid_t nb_lcores; /**< Number of probed logical cores. */
struct fwd_lcore **fwd_lcores; /**< For all probed logical cores. */
lcoreid_t nb_lcores; /**< Number of probed logical cores. */
+portid_t ports_ids[RTE_MAX_ETHPORTS]; /**< Store all port ids. */
+
/*
* Test Forwarding Configuration.
* nb_fwd_lcores <= nb_cfg_lcores <= nb_lcores
/*
* Test Forwarding Configuration.
* nb_fwd_lcores <= nb_cfg_lcores <= nb_lcores
uint64_t tics_per_1sec;
uint64_t tics_datum;
uint64_t tics_current;
uint64_t tics_per_1sec;
uint64_t tics_datum;
uint64_t tics_current;
tics_datum = rte_rdtsc();
tics_per_1sec = rte_get_timer_hz();
#endif
tics_datum = rte_rdtsc();
tics_per_1sec = rte_get_timer_hz();
#endif
tics_current = rte_rdtsc();
if (tics_current - tics_datum >= tics_per_1sec) {
/* Periodic bitrate calculation */
tics_current = rte_rdtsc();
if (tics_current - tics_datum >= tics_per_1sec) {
/* Periodic bitrate calculation */
- RTE_ETH_FOREACH_DEV(idx_port)
+ for (i = 0; i < cnt_ports; i++)
rte_stats_bitrate_calc(bitrate_data,
rte_stats_bitrate_calc(bitrate_data,
tics_datum = tics_current;
}
}
tics_datum = tics_current;
}
}
reconfig(pi, socket_id);
rte_eth_promiscuous_enable(pi);
reconfig(pi, socket_id);
rte_eth_promiscuous_enable(pi);
+ ports_ids[nb_ports] = pi;
nb_ports = rte_eth_dev_count_avail();
ports[pi].port_status = RTE_PORT_STOPPED;
nb_ports = rte_eth_dev_count_avail();
ports[pi].port_status = RTE_PORT_STOPPED;
detach_port(portid_t port_id)
{
char name[RTE_ETH_NAME_MAX_LEN];
detach_port(portid_t port_id)
{
char name[RTE_ETH_NAME_MAX_LEN];
printf("Detaching a port...\n");
printf("Detaching a port...\n");
+ for (i = 0; i < nb_ports; i++) {
+ if (ports_ids[i] == port_id) {
+ ports_ids[i] = ports_ids[nb_ports-1];
+ ports_ids[nb_ports-1] = 0;
+ break;
+ }
+ }
nb_ports = rte_eth_dev_count_avail();
update_fwd_ports(RTE_MAX_ETHPORTS);
nb_ports = rte_eth_dev_count_avail();
update_fwd_ports(RTE_MAX_ETHPORTS);
{
int diag;
portid_t port_id;
{
int diag;
portid_t port_id;
int ret;
signal(SIGINT, signal_handler);
int ret;
signal(SIGINT, signal_handler);
rte_pdump_init(NULL);
#endif
rte_pdump_init(NULL);
#endif
- nb_ports = (portid_t) rte_eth_dev_count_avail();
+ count = 0;
+ RTE_ETH_FOREACH_DEV(port_id) {
+ ports_ids[count] = port_id;
+ count++;
+ }
+ nb_ports = (portid_t) count;
if (nb_ports == 0)
TESTPMD_LOG(WARNING, "No probed ethernet devices\n");
if (nb_ports == 0)
TESTPMD_LOG(WARNING, "No probed ethernet devices\n");