#include <string.h>
#include <time.h>
#include <fcntl.h>
+#ifndef RTE_EXEC_ENV_WINDOWS
#include <sys/mman.h>
+#endif
#include <sys/types.h>
#include <errno.h>
#include <stdbool.h>
#ifdef RTE_LIB_LATENCYSTATS
#include <rte_latencystats.h>
#endif
+#ifdef RTE_EXEC_ENV_WINDOWS
+#include <process.h>
+#endif
#include "testpmd.h"
set_default_fwd_ports_config();
}
+#ifndef RTE_EXEC_ENV_WINDOWS
/* extremely pessimistic estimation of memory required to create a mempool */
static int
calc_mem_size(uint32_t nb_mbufs, uint32_t mbuf_sz, size_t pgsz, size_t *out)
int ret;
RTE_ETH_FOREACH_DEV(pid) {
- struct rte_eth_dev *dev =
- &rte_eth_devices[pid];
+ struct rte_eth_dev_info dev_info;
+
+ ret = eth_dev_info_get_print_err(pid, &dev_info);
+ if (ret != 0) {
+ TESTPMD_LOG(DEBUG,
+ "unable to get device info for port %d on addr 0x%p,"
+ "mempool unmapping will not be performed\n",
+ pid, memhdr->addr);
+ continue;
+ }
- ret = rte_dev_dma_unmap(dev->device, memhdr->addr, 0,
- memhdr->len);
+ ret = rte_dev_dma_unmap(dev_info.device, memhdr->addr, 0, memhdr->len);
if (ret) {
TESTPMD_LOG(DEBUG,
"unable to DMA unmap addr 0x%p "
"for device %s\n",
- memhdr->addr, dev->data->name);
+ memhdr->addr, dev_info.device->name);
}
}
ret = rte_extmem_unregister(memhdr->addr, memhdr->len);
return;
}
RTE_ETH_FOREACH_DEV(pid) {
- struct rte_eth_dev *dev =
- &rte_eth_devices[pid];
+ struct rte_eth_dev_info dev_info;
- ret = rte_dev_dma_map(dev->device, memhdr->addr, 0,
- memhdr->len);
+ ret = eth_dev_info_get_print_err(pid, &dev_info);
+ if (ret != 0) {
+ TESTPMD_LOG(DEBUG,
+ "unable to get device info for port %d on addr 0x%p,"
+ "mempool mapping will not be performed\n",
+ pid, memhdr->addr);
+ continue;
+ }
+ ret = rte_dev_dma_map(dev_info.device, memhdr->addr, 0, memhdr->len);
if (ret) {
TESTPMD_LOG(DEBUG,
"unable to DMA map addr 0x%p "
"for device %s\n",
- memhdr->addr, dev->data->name);
+ memhdr->addr, dev_info.device->name);
}
}
}
+#endif
static unsigned int
setup_extbuf(uint32_t nb_mbufs, uint16_t mbuf_sz, unsigned int socket_id,
{
char pool_name[RTE_MEMPOOL_NAMESIZE];
struct rte_mempool *rte_mp = NULL;
+#ifndef RTE_EXEC_ENV_WINDOWS
uint32_t mb_size;
mb_size = sizeof(struct rte_mbuf) + mbuf_seg_size;
+#endif
mbuf_poolname_build(socket_id, pool_name, sizeof(pool_name), size_idx);
TESTPMD_LOG(INFO,
mb_mempool_cache, 0, mbuf_seg_size, socket_id);
break;
}
+#ifndef RTE_EXEC_ENV_WINDOWS
case MP_ALLOC_ANON:
{
rte_mp = rte_mempool_create_empty(pool_name, nb_mbuf,
heap_socket);
break;
}
+#endif
case MP_ALLOC_XBUF:
{
struct rte_pktmbuf_extmem *ext_mem;
}
}
+#ifndef RTE_EXEC_ENV_WINDOWS
err:
+#endif
if (rte_mp == NULL) {
rte_exit(EXIT_FAILURE,
"Creation of mbuf pool for socket %u failed: %s\n",
if (new_socket_id(socket_id)) {
if (!warning_once && numa_support)
- printf("Warning: NUMA should be configured manually by"
- " using --port-numa-config and"
- " --ring-numa-config parameters along with"
- " --numa.\n");
+ fprintf(stderr,
+ "Warning: NUMA should be configured manually by using --port-numa-config and --ring-numa-config parameters along with --numa.\n");
warning_once = 1;
return -1;
}
allowed_max_rxq = get_allowed_max_nb_rxq(&pid);
if (rxq > allowed_max_rxq) {
- printf("Fail: input rxq (%u) can't be greater "
- "than max_rx_queues (%u) of port %u\n",
- rxq,
- allowed_max_rxq,
- pid);
+ fprintf(stderr,
+ "Fail: input rxq (%u) can't be greater than max_rx_queues (%u) of port %u\n",
+ rxq, allowed_max_rxq, pid);
return -1;
}
return 0;
allowed_max_txq = get_allowed_max_nb_txq(&pid);
if (txq > allowed_max_txq) {
- printf("Fail: input txq (%u) can't be greater "
- "than max_tx_queues (%u) of port %u\n",
- txq,
- allowed_max_txq,
- pid);
+ fprintf(stderr,
+ "Fail: input txq (%u) can't be greater than max_tx_queues (%u) of port %u\n",
+ txq, allowed_max_txq, pid);
return -1;
}
return 0;
allowed_max_rxd = get_allowed_max_nb_rxd(&pid);
if (rxd > allowed_max_rxd) {
- printf("Fail: input rxd (%u) can't be greater "
- "than max_rxds (%u) of port %u\n",
- rxd,
- allowed_max_rxd,
- pid);
+ fprintf(stderr,
+ "Fail: input rxd (%u) can't be greater than max_rxds (%u) of port %u\n",
+ rxd, allowed_max_rxd, pid);
return -1;
}
allowed_min_rxd = get_allowed_min_nb_rxd(&pid);
if (rxd < allowed_min_rxd) {
- printf("Fail: input rxd (%u) can't be less "
- "than min_rxds (%u) of port %u\n",
- rxd,
- allowed_min_rxd,
- pid);
+ fprintf(stderr,
+ "Fail: input rxd (%u) can't be less than min_rxds (%u) of port %u\n",
+ rxd, allowed_min_rxd, pid);
return -1;
}
allowed_max_txd = get_allowed_max_nb_txd(&pid);
if (txd > allowed_max_txd) {
- printf("Fail: input txd (%u) can't be greater "
- "than max_txds (%u) of port %u\n",
- txd,
- allowed_max_txd,
- pid);
+ fprintf(stderr,
+ "Fail: input txd (%u) can't be greater than max_txds (%u) of port %u\n",
+ txd, allowed_max_txd, pid);
return -1;
}
allowed_min_txd = get_allowed_min_nb_txd(&pid);
if (txd < allowed_min_txd) {
- printf("Fail: input txd (%u) can't be less "
- "than min_txds (%u) of port %u\n",
- txd,
- allowed_min_txd,
- pid);
+ fprintf(stderr,
+ "Fail: input txd (%u) can't be less than min_txds (%u) of port %u\n",
+ txd, allowed_min_txd, pid);
return -1;
}
return 0;
allowed_max_hairpinq = get_allowed_max_nb_hairpinq(&pid);
if (hairpinq > allowed_max_hairpinq) {
- printf("Fail: input hairpin (%u) can't be greater "
- "than max_hairpin_queues (%u) of port %u\n",
- hairpinq, allowed_max_hairpinq, pid);
+ fprintf(stderr,
+ "Fail: input hairpin (%u) can't be greater than max_hairpin_queues (%u) of port %u\n",
+ hairpinq, allowed_max_hairpinq, pid);
return -1;
}
return 0;
}
+static void
+init_config_port_offloads(portid_t pid, uint32_t socket_id)
+{
+ struct rte_port *port = &ports[pid];
+ uint16_t data_size;
+ int ret;
+ int i;
+
+ port->dev_conf.txmode = tx_mode;
+ port->dev_conf.rxmode = rx_mode;
+
+ ret = eth_dev_info_get_print_err(pid, &port->dev_info);
+ if (ret != 0)
+ rte_exit(EXIT_FAILURE, "rte_eth_dev_info_get() failed\n");
+
+ ret = update_jumbo_frame_offload(pid);
+ if (ret != 0)
+ fprintf(stderr,
+ "Updating jumbo frame offload failed for port %u\n",
+ pid);
+
+ if (!(port->dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE))
+ port->dev_conf.txmode.offloads &=
+ ~DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+ /* Apply Rx offloads configuration */
+ for (i = 0; i < port->dev_info.max_rx_queues; i++)
+ port->rx_conf[i].offloads = port->dev_conf.rxmode.offloads;
+ /* Apply Tx offloads configuration */
+ for (i = 0; i < port->dev_info.max_tx_queues; i++)
+ port->tx_conf[i].offloads = port->dev_conf.txmode.offloads;
+
+ if (eth_link_speed)
+ port->dev_conf.link_speeds = eth_link_speed;
+
+ /* set flag to initialize port/queue */
+ port->need_reconfig = 1;
+ port->need_reconfig_queues = 1;
+ port->socket_id = socket_id;
+ port->tx_metadata = 0;
+
+ /*
+ * Check for maximum number of segments per MTU.
+ * Accordingly update the mbuf data size.
+ */
+ if (port->dev_info.rx_desc_lim.nb_mtu_seg_max != UINT16_MAX &&
+ port->dev_info.rx_desc_lim.nb_mtu_seg_max != 0) {
+ data_size = rx_mode.max_rx_pkt_len /
+ port->dev_info.rx_desc_lim.nb_mtu_seg_max;
+
+ if ((data_size + RTE_PKTMBUF_HEADROOM) > mbuf_data_size[0]) {
+ mbuf_data_size[0] = data_size + RTE_PKTMBUF_HEADROOM;
+ TESTPMD_LOG(WARNING,
+ "Configured mbuf size of the first segment %hu\n",
+ mbuf_data_size[0]);
+ }
+ }
+}
+
static void
init_config(void)
{
portid_t pid;
- struct rte_port *port;
struct rte_mempool *mbp;
unsigned int nb_mbuf_per_pool;
lcoreid_t lc_id;
- uint8_t port_per_socket[RTE_MAX_NUMA_NODES];
struct rte_gro_param gro_param;
uint32_t gso_types;
- uint16_t data_size;
- bool warning = 0;
- int k;
- int ret;
-
- memset(port_per_socket,0,RTE_MAX_NUMA_NODES);
/* Configuration of logical cores. */
fwd_lcores = rte_zmalloc("testpmd: fwd_lcores",
}
RTE_ETH_FOREACH_DEV(pid) {
- port = &ports[pid];
- /* Apply default TxRx configuration for all ports */
- port->dev_conf.txmode = tx_mode;
- port->dev_conf.rxmode = rx_mode;
-
- ret = eth_dev_info_get_print_err(pid, &port->dev_info);
- if (ret != 0)
- rte_exit(EXIT_FAILURE,
- "rte_eth_dev_info_get() failed\n");
-
- ret = update_jumbo_frame_offload(pid);
- if (ret != 0)
- printf("Updating jumbo frame offload failed for port %u\n",
- pid);
+ uint32_t socket_id;
- if (!(port->dev_info.tx_offload_capa &
- DEV_TX_OFFLOAD_MBUF_FAST_FREE))
- port->dev_conf.txmode.offloads &=
- ~DEV_TX_OFFLOAD_MBUF_FAST_FREE;
if (numa_support) {
- if (port_numa[pid] != NUMA_NO_CONFIG)
- port_per_socket[port_numa[pid]]++;
- else {
- uint32_t socket_id = rte_eth_dev_socket_id(pid);
+ socket_id = port_numa[pid];
+ if (port_numa[pid] == NUMA_NO_CONFIG) {
+ socket_id = rte_eth_dev_socket_id(pid);
/*
* if socket_id is invalid,
*/
if (check_socket_id(socket_id) < 0)
socket_id = socket_ids[0];
- port_per_socket[socket_id]++;
- }
- }
-
- /* Apply Rx offloads configuration */
- for (k = 0; k < port->dev_info.max_rx_queues; k++)
- port->rx_conf[k].offloads =
- port->dev_conf.rxmode.offloads;
- /* Apply Tx offloads configuration */
- for (k = 0; k < port->dev_info.max_tx_queues; k++)
- port->tx_conf[k].offloads =
- port->dev_conf.txmode.offloads;
-
- if (eth_link_speed)
- port->dev_conf.link_speeds = eth_link_speed;
-
- /* set flag to initialize port/queue */
- port->need_reconfig = 1;
- port->need_reconfig_queues = 1;
- port->tx_metadata = 0;
-
- /* Check for maximum number of segments per MTU. Accordingly
- * update the mbuf data size.
- */
- if (port->dev_info.rx_desc_lim.nb_mtu_seg_max != UINT16_MAX &&
- port->dev_info.rx_desc_lim.nb_mtu_seg_max != 0) {
- data_size = rx_mode.max_rx_pkt_len /
- port->dev_info.rx_desc_lim.nb_mtu_seg_max;
-
- if ((data_size + RTE_PKTMBUF_HEADROOM) >
- mbuf_data_size[0]) {
- mbuf_data_size[0] = data_size +
- RTE_PKTMBUF_HEADROOM;
- warning = 1;
}
+ } else {
+ socket_id = (socket_num == UMA_NO_CONFIG) ?
+ 0 : socket_num;
}
+ /* Apply default TxRx configuration for all ports */
+ init_config_port_offloads(pid, socket_id);
}
-
- if (warning)
- TESTPMD_LOG(WARNING,
- "Configured mbuf size of the first segment %hu\n",
- mbuf_data_size[0]);
/*
* Create pools of mbuf.
* If NUMA support is disabled, create a single pool of mbuf in
void
reconfig(portid_t new_port_id, unsigned socket_id)
{
- struct rte_port *port;
- int ret;
-
/* Reconfiguration of Ethernet ports. */
- port = &ports[new_port_id];
-
- ret = eth_dev_info_get_print_err(new_port_id, &port->dev_info);
- if (ret != 0)
- return;
-
- /* set flag to initialize port/queue */
- port->need_reconfig = 1;
- port->need_reconfig_queues = 1;
- port->socket_id = socket_id;
-
+ init_config_port_offloads(new_port_id, socket_id);
init_port_config();
}
RTE_ETH_FOREACH_DEV(pid) {
port = &ports[pid];
if (nb_rxq > port->dev_info.max_rx_queues) {
- printf("Fail: nb_rxq(%d) is greater than "
- "max_rx_queues(%d)\n", nb_rxq,
- port->dev_info.max_rx_queues);
+ fprintf(stderr,
+ "Fail: nb_rxq(%d) is greater than max_rx_queues(%d)\n",
+ nb_rxq, port->dev_info.max_rx_queues);
return -1;
}
if (nb_txq > port->dev_info.max_tx_queues) {
- printf("Fail: nb_txq(%d) is greater than "
- "max_tx_queues(%d)\n", nb_txq,
- port->dev_info.max_tx_queues);
+ fprintf(stderr,
+ "Fail: nb_txq(%d) is greater than max_tx_queues(%d)\n",
+ nb_txq, port->dev_info.max_tx_queues);
return -1;
}
if (numa_support) {
q = RTE_MAX(nb_rxq, nb_txq);
if (q == 0) {
- printf("Fail: Cannot allocate fwd streams as number of queues is 0\n");
+ fprintf(stderr,
+ "Fail: Cannot allocate fwd streams as number of queues is 0\n");
return -1;
}
nb_fwd_streams_new = (streamid_t)(nb_ports * q);
diag = rte_eal_remote_launch(pkt_fwd_on_lcore,
fwd_lcores[i], lc_id);
if (diag != 0)
- printf("launch lcore %u failed - diag=%d\n",
- lc_id, diag);
+ fprintf(stderr,
+ "launch lcore %u failed - diag=%d\n",
+ lc_id, diag);
}
}
}
cur_fwd_eng->fwd_mode_name);
if (all_ports_started() == 0) {
- printf("Not all ports were started\n");
+ fprintf(stderr, "Not all ports were started\n");
return;
}
if (test_done == 0) {
- printf("Packet forwarding already started\n");
+ fprintf(stderr, "Packet forwarding already started\n");
return;
}
test_done = 0;
int i;
if (test_done) {
- printf("Packet forwarding not started\n");
+ fprintf(stderr, "Packet forwarding not started\n");
return;
}
printf("Telling cores to stop...");
dev_set_link_up(portid_t pid)
{
if (rte_eth_dev_set_link_up(pid) < 0)
- printf("\nSet link up fail.\n");
+ fprintf(stderr, "\nSet link up fail.\n");
}
void
dev_set_link_down(portid_t pid)
{
if (rte_eth_dev_set_link_down(pid) < 0)
- printf("\nSet link down fail.\n");
+ fprintf(stderr, "\nSet link down fail.\n");
}
static int
if (rte_atomic16_cmpset(&(port->port_status),
RTE_PORT_HANDLING,
RTE_PORT_STOPPED) == 0)
- printf("Port %d can not be set back "
- "to stopped\n", pi);
- printf("Fail to configure port %d hairpin "
- "queues\n", pi);
+ fprintf(stderr,
+ "Port %d can not be set back to stopped\n", pi);
+ fprintf(stderr, "Fail to configure port %d hairpin queues\n",
+ pi);
/* try to reconfigure queues next time */
port->need_reconfig_queues = 1;
return -1;
if (rte_atomic16_cmpset(&(port->port_status),
RTE_PORT_HANDLING,
RTE_PORT_STOPPED) == 0)
- printf("Port %d can not be set back "
- "to stopped\n", pi);
- printf("Fail to configure port %d hairpin "
- "queues\n", pi);
+ fprintf(stderr,
+ "Port %d can not be set back to stopped\n", pi);
+ fprintf(stderr, "Fail to configure port %d hairpin queues\n",
+ pi);
/* try to reconfigure queues next time */
port->need_reconfig_queues = 1;
return -1;
int peer_pi;
queueid_t qi;
struct rte_port *port;
- struct rte_ether_addr mac_addr;
struct rte_eth_hairpin_cap cap;
if (port_id_is_invalid(pid, ENABLED_WARN))
port = &ports[pi];
if (rte_atomic16_cmpset(&(port->port_status), RTE_PORT_STOPPED,
RTE_PORT_HANDLING) == 0) {
- printf("Port %d is now not stopped\n", pi);
+ fprintf(stderr, "Port %d is now not stopped\n", pi);
continue;
}
if (flow_isolate_all) {
int ret = port_flow_isolate(pi, 1);
if (ret) {
- printf("Failed to apply isolated"
- " mode on port %d\n", pi);
+ fprintf(stderr,
+ "Failed to apply isolated mode on port %d\n",
+ pi);
return -1;
}
}
port->socket_id);
if (nb_hairpinq > 0 &&
rte_eth_dev_hairpin_capability_get(pi, &cap)) {
- printf("Port %d doesn't support hairpin "
- "queues\n", pi);
+ fprintf(stderr,
+ "Port %d doesn't support hairpin queues\n",
+ pi);
return -1;
}
/* configure port */
if (diag != 0) {
if (rte_atomic16_cmpset(&(port->port_status),
RTE_PORT_HANDLING, RTE_PORT_STOPPED) == 0)
- printf("Port %d can not be set back "
- "to stopped\n", pi);
- printf("Fail to configure port %d\n", pi);
+ fprintf(stderr,
+ "Port %d can not be set back to stopped\n",
+ pi);
+ fprintf(stderr, "Fail to configure port %d\n",
+ pi);
/* try to reconfigure port next time */
port->need_reconfig = 1;
return -1;
if (rte_atomic16_cmpset(&(port->port_status),
RTE_PORT_HANDLING,
RTE_PORT_STOPPED) == 0)
- printf("Port %d can not be set back "
- "to stopped\n", pi);
- printf("Fail to configure port %d tx queues\n",
- pi);
+ fprintf(stderr,
+ "Port %d can not be set back to stopped\n",
+ pi);
+ fprintf(stderr,
+ "Fail to configure port %d tx queues\n",
+ pi);
/* try to reconfigure queues next time */
port->need_reconfig_queues = 1;
return -1;
mbuf_pool_find
(rxring_numa[pi], 0);
if (mp == NULL) {
- printf("Failed to setup RX queue:"
- "No mempool allocation"
- " on the socket %d\n",
+ fprintf(stderr,
+ "Failed to setup RX queue: No mempool allocation on the socket %d\n",
rxring_numa[pi]);
return -1;
}
mbuf_pool_find
(port->socket_id, 0);
if (mp == NULL) {
- printf("Failed to setup RX queue:"
- "No mempool allocation"
- " on the socket %d\n",
+ fprintf(stderr,
+ "Failed to setup RX queue: No mempool allocation on the socket %d\n",
port->socket_id);
return -1;
}
if (rte_atomic16_cmpset(&(port->port_status),
RTE_PORT_HANDLING,
RTE_PORT_STOPPED) == 0)
- printf("Port %d can not be set back "
- "to stopped\n", pi);
- printf("Fail to configure port %d rx queues\n",
- pi);
+ fprintf(stderr,
+ "Port %d can not be set back to stopped\n",
+ pi);
+ fprintf(stderr,
+ "Fail to configure port %d rx queues\n",
+ pi);
/* try to reconfigure queues next time */
port->need_reconfig_queues = 1;
return -1;
diag = rte_eth_dev_set_ptypes(pi, RTE_PTYPE_UNKNOWN,
NULL, 0);
if (diag < 0)
- printf(
- "Port %d: Failed to disable Ptype parsing\n",
- pi);
+ fprintf(stderr,
+ "Port %d: Failed to disable Ptype parsing\n",
+ pi);
}
p_pi = pi;
/* start port */
diag = rte_eth_dev_start(pi);
if (diag < 0) {
- printf("Fail to start port %d: %s\n", pi,
- rte_strerror(-diag));
+ fprintf(stderr, "Fail to start port %d: %s\n",
+ pi, rte_strerror(-diag));
/* Fail to setup rx queue, return */
if (rte_atomic16_cmpset(&(port->port_status),
RTE_PORT_HANDLING, RTE_PORT_STOPPED) == 0)
- printf("Port %d can not be set back to "
- "stopped\n", pi);
+ fprintf(stderr,
+ "Port %d can not be set back to stopped\n",
+ pi);
continue;
}
if (rte_atomic16_cmpset(&(port->port_status),
RTE_PORT_HANDLING, RTE_PORT_STARTED) == 0)
- printf("Port %d can not be set into started\n", pi);
+ fprintf(stderr, "Port %d can not be set into started\n",
+ pi);
- if (eth_macaddr_get_print_err(pi, &mac_addr) == 0)
+ if (eth_macaddr_get_print_err(pi, &port->eth_addr) == 0)
printf("Port %d: %02X:%02X:%02X:%02X:%02X:%02X\n", pi,
- mac_addr.addr_bytes[0], mac_addr.addr_bytes[1],
- mac_addr.addr_bytes[2], mac_addr.addr_bytes[3],
- mac_addr.addr_bytes[4], mac_addr.addr_bytes[5]);
+ port->eth_addr.addr_bytes[0],
+ port->eth_addr.addr_bytes[1],
+ port->eth_addr.addr_bytes[2],
+ port->eth_addr.addr_bytes[3],
+ port->eth_addr.addr_bytes[4],
+ port->eth_addr.addr_bytes[5]);
/* at least one port started, need checking link status */
need_check_link_status = 1;
if (need_check_link_status == 1 && !no_link_check)
check_all_ports_link_status(RTE_PORT_ALL);
else if (need_check_link_status == 0)
- printf("Please stop the ports first\n");
+ fprintf(stderr, "Please stop the ports first\n");
if (hairpin_mode & 0xf) {
uint16_t i;
continue;
diag = rte_eth_hairpin_bind(pi, peer_pl[j]);
if (diag < 0) {
- printf("Error during binding hairpin"
- " Tx port %u to %u: %s\n",
- pi, peer_pl[j],
- rte_strerror(-diag));
+ fprintf(stderr,
+ "Error during binding hairpin Tx port %u to %u: %s\n",
+ pi, peer_pl[j],
+ rte_strerror(-diag));
return -1;
}
}
continue;
diag = rte_eth_hairpin_bind(peer_pl[j], pi);
if (diag < 0) {
- printf("Error during binding hairpin"
- " Tx port %u to %u: %s\n",
- peer_pl[j], pi,
- rte_strerror(-diag));
+ fprintf(stderr,
+ "Error during binding hairpin Tx port %u to %u: %s\n",
+ peer_pl[j], pi,
+ rte_strerror(-diag));
return -1;
}
}
continue;
if (port_is_forwarding(pi) != 0 && test_done == 0) {
- printf("Please remove port %d from forwarding configuration.\n", pi);
+ fprintf(stderr,
+ "Please remove port %d from forwarding configuration.\n",
+ pi);
continue;
}
if (port_is_bonding_slave(pi)) {
- printf("Please remove port %d from bonded device.\n", pi);
+ fprintf(stderr,
+ "Please remove port %d from bonded device.\n",
+ pi);
continue;
}
if (rte_atomic16_cmpset(&(port->port_status),
RTE_PORT_HANDLING, RTE_PORT_STOPPED) == 0)
- printf("Port %d can not be set into stopped\n", pi);
+ fprintf(stderr, "Port %d can not be set into stopped\n",
+ pi);
need_check_link_status = 1;
}
if (need_check_link_status && !no_link_check)
continue;
if (port_is_forwarding(pi) != 0 && test_done == 0) {
- printf("Please remove port %d from forwarding configuration.\n", pi);
+ fprintf(stderr,
+ "Please remove port %d from forwarding configuration.\n",
+ pi);
continue;
}
if (port_is_bonding_slave(pi)) {
- printf("Please remove port %d from bonded device.\n", pi);
+ fprintf(stderr,
+ "Please remove port %d from bonded device.\n",
+ pi);
continue;
}
port = &ports[pi];
if (rte_atomic16_cmpset(&(port->port_status),
RTE_PORT_CLOSED, RTE_PORT_CLOSED) == 1) {
- printf("Port %d is already closed\n", pi);
+ fprintf(stderr, "Port %d is already closed\n", pi);
continue;
}
if ((pid == (portid_t)RTE_PORT_ALL && !all_ports_stopped()) ||
(pid != (portid_t)RTE_PORT_ALL && !port_is_stopped(pid))) {
- printf("Can not reset port(s), please stop port(s) first.\n");
+ fprintf(stderr,
+ "Can not reset port(s), please stop port(s) first.\n");
return;
}
continue;
if (port_is_forwarding(pi) != 0 && test_done == 0) {
- printf("Please remove port %d from forwarding "
- "configuration.\n", pi);
+ fprintf(stderr,
+ "Please remove port %d from forwarding configuration.\n",
+ pi);
continue;
}
if (port_is_bonding_slave(pi)) {
- printf("Please remove port %d from bonded device.\n",
- pi);
+ fprintf(stderr,
+ "Please remove port %d from bonded device.\n",
+ pi);
continue;
}
port->need_reconfig = 1;
port->need_reconfig_queues = 1;
} else {
- printf("Failed to reset port %d. diag=%d\n", pi, diag);
+ fprintf(stderr, "Failed to reset port %d. diag=%d\n",
+ pi, diag);
}
}
printf("Attaching a new port...\n");
if (identifier == NULL) {
- printf("Invalid parameters are specified\n");
+ fprintf(stderr, "Invalid parameters are specified\n");
return;
}
reconfig(pi, socket_id);
ret = rte_eth_promiscuous_enable(pi);
if (ret != 0)
- printf("Error during enabling promiscuous mode for port %u: %s - ignore\n",
+ fprintf(stderr,
+ "Error during enabling promiscuous mode for port %u: %s - ignore\n",
pi, rte_strerror(-ret));
ports_ids[nb_ports++] = pi;
portid_t sibling;
if (dev == NULL) {
- printf("Device already removed\n");
+ fprintf(stderr, "Device already removed\n");
return;
}
RTE_ETH_FOREACH_DEV_OF(sibling, dev) {
if (ports[sibling].port_status != RTE_PORT_CLOSED) {
if (ports[sibling].port_status != RTE_PORT_STOPPED) {
- printf("Port %u not stopped\n", sibling);
+ fprintf(stderr, "Port %u not stopped\n",
+ sibling);
return;
}
port_flow_flush(sibling);
void
detach_port_device(portid_t port_id)
{
+ int ret;
+ struct rte_eth_dev_info dev_info;
+
if (port_id_is_invalid(port_id, ENABLED_WARN))
return;
if (ports[port_id].port_status != RTE_PORT_CLOSED) {
if (ports[port_id].port_status != RTE_PORT_STOPPED) {
- printf("Port not stopped\n");
+ fprintf(stderr, "Port not stopped\n");
return;
}
- printf("Port was not closed\n");
+ fprintf(stderr, "Port was not closed\n");
}
- detach_device(rte_eth_devices[port_id].device);
+ ret = eth_dev_info_get_print_err(port_id, &dev_info);
+ if (ret != 0) {
+ TESTPMD_LOG(ERR,
+ "Failed to get device info for port %d, not detaching\n",
+ port_id);
+ return;
+ }
+ detach_device(dev_info.device);
}
void
memset(&da, 0, sizeof(da));
if (rte_devargs_parsef(&da, "%s", identifier)) {
- printf("cannot parse identifier\n");
+ fprintf(stderr, "cannot parse identifier\n");
return;
}
RTE_ETH_FOREACH_MATCHING_DEV(port_id, identifier, &iterator) {
if (ports[port_id].port_status != RTE_PORT_CLOSED) {
if (ports[port_id].port_status != RTE_PORT_STOPPED) {
- printf("Port %u not stopped\n", port_id);
+ fprintf(stderr, "Port %u not stopped\n",
+ port_id);
rte_eth_iterator_cleanup(&iterator);
rte_devargs_reset(&da);
return;
if (test_done == 0)
stop_packet_forwarding();
+#ifndef RTE_EXEC_ENV_WINDOWS
for (i = 0 ; i < RTE_DIM(mempools) ; i++) {
if (mempools[i]) {
if (mp_alloc_type == MP_ALLOC_ANON)
NULL);
}
}
+#endif
if (ports != NULL) {
no_link_check = 1;
RTE_ETH_FOREACH_DEV(pt_id) {
if (ret < 0) {
all_ports_up = 0;
if (print_flag == 1)
- printf("Port %u link get failed: %s\n",
+ fprintf(stderr,
+ "Port %u link get failed: %s\n",
portid, rte_strerror(-ret));
continue;
}
int need_to_start = 0;
int org_no_link_check = no_link_check;
portid_t port_id = (intptr_t)arg;
- struct rte_device *dev;
+ struct rte_eth_dev_info dev_info;
+ int ret;
RTE_ETH_VALID_PORTID_OR_RET(port_id);
stop_port(port_id);
no_link_check = org_no_link_check;
- /* Save rte_device pointer before closing ethdev port */
- dev = rte_eth_devices[port_id].device;
- close_port(port_id);
- detach_device(dev); /* might be already removed or have more ports */
-
+ ret = eth_dev_info_get_print_err(port_id, &dev_info);
+ if (ret != 0)
+ TESTPMD_LOG(ERR,
+ "Failed to get device info for port %d, not detaching\n",
+ port_id);
+ else {
+ struct rte_device *device = dev_info.device;
+ close_port(port_id);
+ detach_device(device); /* might be already removed or have more ports */
+ }
if (need_to_start)
start_packet_forwarding(0);
}
RTE_SET_USED(ret_param);
if (type >= RTE_ETH_EVENT_MAX) {
- fprintf(stderr, "\nPort %" PRIu16 ": %s called upon invalid event %d\n",
+ fprintf(stderr,
+ "\nPort %" PRIu16 ": %s called upon invalid event %d\n",
port_id, __func__, type);
fflush(stderr);
} else if (event_print_mask & (UINT32_C(1) << type)) {
break;
if (rte_eal_alarm_set(100000,
rmv_port_callback, (void *)(intptr_t)port_id))
- fprintf(stderr, "Could not set up deferred device removal\n");
+ fprintf(stderr,
+ "Could not set up deferred device removal\n");
break;
case RTE_ETH_EVENT_DESTROY:
ports[port_id].port_status = RTE_PORT_CLOSED;
on = false;
} else {
if ((port->dev_info.rx_offload_capa & DEV_RX_OFFLOAD_JUMBO_FRAME) == 0) {
- printf("Frame size (%u) is not supported by port %u\n",
+ fprintf(stderr,
+ "Frame size (%u) is not supported by port %u\n",
port->dev_conf.rxmode.max_rx_pkt_len,
portid);
return -1;
ret = rte_eth_dev_set_mtu(portid,
port->dev_conf.rxmode.max_rx_pkt_len - eth_overhead);
if (ret)
- printf("Failed to set MTU to %u for port %u\n",
+ fprintf(stderr,
+ "Failed to set MTU to %u for port %u\n",
port->dev_conf.rxmode.max_rx_pkt_len - eth_overhead,
portid);
}
rte_pmd_ixgbe_bypass_init(pid);
#endif
- if (lsc_interrupt &&
- (rte_eth_devices[pid].data->dev_flags &
- RTE_ETH_DEV_INTR_LSC))
+ if (lsc_interrupt && (*port->dev_info.dev_flags & RTE_ETH_DEV_INTR_LSC))
port->dev_conf.intr_conf.lsc = 1;
- if (rmv_interrupt &&
- (rte_eth_devices[pid].data->dev_flags &
- RTE_ETH_DEV_INTR_RMV))
+ if (rmv_interrupt && (*port->dev_info.dev_flags & RTE_ETH_DEV_INTR_RMV))
port->dev_conf.intr_conf.rmv = 1;
}
}
uint8_t port_is_bonding_slave(portid_t slave_pid)
{
struct rte_port *port;
+ struct rte_eth_dev_info dev_info;
+ int ret;
port = &ports[slave_pid];
- if ((rte_eth_devices[slave_pid].data->dev_flags &
- RTE_ETH_DEV_BONDED_SLAVE) || (port->slave_flag == 1))
+ ret = eth_dev_info_get_print_err(slave_pid, &dev_info);
+ if (ret != 0) {
+ TESTPMD_LOG(ERR,
+ "Failed to get device info for port id %d,"
+ "cannot determine if the port is a bonded slave",
+ slave_pid);
+ return 0;
+ }
+ if ((*dev_info.dev_flags & RTE_ETH_DEV_BONDED_SLAVE) || (port->slave_flag == 1))
return 1;
return 0;
}
*/
if (dcb_mode == DCB_VT_ENABLED &&
rte_port->dev_info.vmdq_pool_base > 0) {
- printf("VMDQ_DCB multi-queue mode is nonsensical"
- " for port %d.", pid);
+ fprintf(stderr,
+ "VMDQ_DCB multi-queue mode is nonsensical for port %d.\n",
+ pid);
return -1;
}
signal_handler(int signum)
{
if (signum == SIGINT || signum == SIGTERM) {
- printf("\nSignal %d received, preparing to exit...\n",
- signum);
+ fprintf(stderr, "\nSignal %d received, preparing to exit...\n",
+ signum);
#ifdef RTE_LIB_PDUMP
/* uninitialize packet capture framework */
rte_pdump_uninit();
/* Set flag to indicate the force termination. */
f_quit = 1;
/* exit with the expected status */
+#ifndef RTE_EXEC_ENV_WINDOWS
signal(signum, SIG_DFL);
kill(getpid(), signum);
+#endif
}
}
if (argc > 1)
launch_args_parse(argc, argv);
+#ifndef RTE_EXEC_ENV_WINDOWS
if (do_mlockall && mlockall(MCL_CURRENT | MCL_FUTURE)) {
TESTPMD_LOG(NOTICE, "mlockall() failed with error \"%s\"\n",
strerror(errno));
}
+#endif
if (tx_first && interactive)
rte_exit(EXIT_FAILURE, "--tx-first cannot be used on "
"interactive mode.\n");
if (tx_first && lsc_interrupt) {
- printf("Warning: lsc_interrupt needs to be off when "
- " using tx_first. Disabling.\n");
+ fprintf(stderr,
+ "Warning: lsc_interrupt needs to be off when using tx_first. Disabling.\n");
lsc_interrupt = 0;
}
if (!nb_rxq && !nb_txq)
- printf("Warning: Either rx or tx queues should be non-zero\n");
+ fprintf(stderr,
+ "Warning: Either rx or tx queues should be non-zero\n");
if (nb_rxq > 1 && nb_rxq > nb_txq)
- printf("Warning: nb_rxq=%d enables RSS configuration, "
- "but nb_txq=%d will prevent to fully test it.\n",
- nb_rxq, nb_txq);
+ fprintf(stderr,
+ "Warning: nb_rxq=%d enables RSS configuration, but nb_txq=%d will prevent to fully test it.\n",
+ nb_rxq, nb_txq);
init_config();
RTE_ETH_FOREACH_DEV(port_id) {
ret = rte_eth_promiscuous_enable(port_id);
if (ret != 0)
- printf("Error during enabling promiscuous mode for port %u: %s - ignore\n",
+ fprintf(stderr,
+ "Error during enabling promiscuous mode for port %u: %s - ignore\n",
port_id, rte_strerror(-ret));
}
if (latencystats_enabled != 0) {
int ret = rte_latencystats_init(1, NULL);
if (ret)
- printf("Warning: latencystats init()"
- " returned error %d\n", ret);
- printf("Latencystats running on lcore %d\n",
+ fprintf(stderr,
+ "Warning: latencystats init() returned error %d\n",
+ ret);
+ fprintf(stderr, "Latencystats running on lcore %d\n",
latencystats_lcore_id);
}
#endif
}
/* Sleep to avoid unnecessary checks */
prev_time = cur_time;
- sleep(1);
+ rte_delay_us_sleep(US_PER_S);
}
}