uint16_t nb_pkt_per_burst = DEF_PKT_BURST; /**< Number of packets per burst. */
uint16_t nb_pkt_flowgen_clones; /**< Number of Tx packet clones to send in flowgen mode. */
+int nb_flows_flowgen = 1024; /**< Number of flows in flowgen mode. */
uint16_t mb_mempool_cache = DEF_MBUF_CACHE; /**< Size of mbuf mempool cache. */
/* current configuration is in DCB or not,0 means it is not in DCB mode */
*/
uint32_t eth_link_speed;
+/*
+ * ID of the current process in multi-process, used to
+ * configure the queues to be polled.
+ */
+int proc_id;
+
+/*
+ * Number of processes in multi-process, used to
+ * configure the queues to be polled.
+ */
+unsigned int num_procs = 1;
+
+static void
+eth_rx_metadata_negotiate_mp(uint16_t port_id)
+{
+ uint64_t rx_meta_features = 0;
+ int ret;
+
+ if (!is_proc_primary())
+ return;
+
+ rx_meta_features |= RTE_ETH_RX_METADATA_USER_FLAG;
+ rx_meta_features |= RTE_ETH_RX_METADATA_USER_MARK;
+ rx_meta_features |= RTE_ETH_RX_METADATA_TUNNEL_ID;
+
+ ret = rte_eth_rx_metadata_negotiate(port_id, &rx_meta_features);
+ if (ret == 0) {
+ if (!(rx_meta_features & RTE_ETH_RX_METADATA_USER_FLAG)) {
+ TESTPMD_LOG(DEBUG, "Flow action FLAG will not affect Rx mbufs on port %u\n",
+ port_id);
+ }
+
+ if (!(rx_meta_features & RTE_ETH_RX_METADATA_USER_MARK)) {
+ TESTPMD_LOG(DEBUG, "Flow action MARK will not affect Rx mbufs on port %u\n",
+ port_id);
+ }
+
+ if (!(rx_meta_features & RTE_ETH_RX_METADATA_TUNNEL_ID)) {
+ TESTPMD_LOG(DEBUG, "Flow tunnel offload support might be limited or unavailable on port %u\n",
+ port_id);
+ }
+ } else if (ret != -ENOTSUP) {
+ rte_exit(EXIT_FAILURE, "Error when negotiating Rx meta features on port %u: %s\n",
+ port_id, rte_strerror(-ret));
+ }
+}
+
+static int
+eth_dev_configure_mp(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
+ const struct rte_eth_conf *dev_conf)
+{
+ if (is_proc_primary())
+ return rte_eth_dev_configure(port_id, nb_rx_q, nb_tx_q,
+ dev_conf);
+ return 0;
+}
+
+static int
+eth_dev_start_mp(uint16_t port_id)
+{
+ if (is_proc_primary())
+ return rte_eth_dev_start(port_id);
+
+ return 0;
+}
+
+static int
+eth_dev_stop_mp(uint16_t port_id)
+{
+ if (is_proc_primary())
+ return rte_eth_dev_stop(port_id);
+
+ return 0;
+}
+
+static void
+mempool_free_mp(struct rte_mempool *mp)
+{
+ if (is_proc_primary())
+ rte_mempool_free(mp);
+}
+
+static int
+eth_dev_set_mtu_mp(uint16_t port_id, uint16_t mtu)
+{
+ if (is_proc_primary())
+ return rte_eth_dev_set_mtu(port_id, mtu);
+
+ return 0;
+}
+
/* Forward function declarations */
static void setup_attached_port(portid_t pi);
static void check_all_ports_link_status(uint32_t port_mask);
mb_size = sizeof(struct rte_mbuf) + mbuf_seg_size;
#endif
mbuf_poolname_build(socket_id, pool_name, sizeof(pool_name), size_idx);
+ if (!is_proc_primary()) {
+ rte_mp = rte_mempool_lookup(pool_name);
+ if (rte_mp == NULL)
+ rte_exit(EXIT_FAILURE,
+ "Get mbuf pool for socket %u failed: %s\n",
+ socket_id, rte_strerror(rte_errno));
+ return rte_mp;
+ }
TESTPMD_LOG(INFO,
"create a new mbuf pool <%s>: n=%u, size=%u, socket=%u\n",
int ret;
int i;
+ eth_rx_metadata_negotiate_mp(pid);
+
port->dev_conf.txmode = tx_mode;
port->dev_conf.rxmode = rx_mode;
uint64_t prev_tsc = 0, diff_tsc, cur_tsc, timer_tsc = 0;
uint64_t timer_period;
+ if (num_procs > 1) {
+ printf("multi-process not support for flushing fwd Rx queues, skip the below lines and return.\n");
+ return;
+ }
+
/* convert to number of cycles */
timer_period = rte_get_timer_hz(); /* 1 second timeout */
static void
launch_packet_forwarding(lcore_function_t *pkt_fwd_on_lcore)
{
- port_fwd_begin_t port_fwd_begin;
unsigned int i;
unsigned int lc_id;
int diag;
- port_fwd_begin = cur_fwd_config.fwd_eng->port_fwd_begin;
- if (port_fwd_begin != NULL) {
- for (i = 0; i < cur_fwd_config.nb_fwd_ports; i++)
- (*port_fwd_begin)(fwd_ports_ids[i]);
- }
for (i = 0; i < cur_fwd_config.nb_fwd_lcores; i++) {
lc_id = fwd_lcores_cpuids[i];
if ((interactive == 0) || (lc_id != rte_lcore_id())) {
fprintf(stderr, "Packet forwarding already started\n");
return;
}
- test_done = 0;
fwd_config_setup();
+ port_fwd_begin = cur_fwd_config.fwd_eng->port_fwd_begin;
+ if (port_fwd_begin != NULL) {
+ for (i = 0; i < cur_fwd_config.nb_fwd_ports; i++) {
+ if (port_fwd_begin(fwd_ports_ids[i])) {
+ fprintf(stderr,
+ "Packet forwarding is not ready\n");
+ return;
+ }
+ }
+ }
+
+ if (with_tx_first) {
+ port_fwd_begin = tx_only_engine.port_fwd_begin;
+ if (port_fwd_begin != NULL) {
+ for (i = 0; i < cur_fwd_config.nb_fwd_ports; i++) {
+ if (port_fwd_begin(fwd_ports_ids[i])) {
+ fprintf(stderr,
+ "Packet forwarding is not ready\n");
+ return;
+ }
+ }
+ }
+ }
+
+ test_done = 0;
+
if(!no_flush_rx)
flush_fwd_rx_queues();
fwd_stats_reset();
if (with_tx_first) {
- port_fwd_begin = tx_only_engine.port_fwd_begin;
- if (port_fwd_begin != NULL) {
- for (i = 0; i < cur_fwd_config.nb_fwd_ports; i++)
- (*port_fwd_begin)(fwd_ports_ids[i]);
- }
while (with_tx_first--) {
launch_packet_forwarding(
run_one_txonly_burst_on_core);
return -1;
}
/* configure port */
- diag = rte_eth_dev_configure(pi, nb_rxq + nb_hairpinq,
+ diag = eth_dev_configure_mp(pi, nb_rxq + nb_hairpinq,
nb_txq + nb_hairpinq,
&(port->dev_conf));
if (diag != 0) {
return -1;
}
}
- if (port->need_reconfig_queues > 0) {
+ if (port->need_reconfig_queues > 0 && is_proc_primary()) {
port->need_reconfig_queues = 0;
/* setup tx queues */
for (qi = 0; qi < nb_txq; qi++) {
cnt_pi++;
/* start port */
- diag = rte_eth_dev_start(pi);
+ diag = eth_dev_start_mp(pi);
if (diag < 0) {
fprintf(stderr, "Fail to start port %d: %s\n",
pi, rte_strerror(-diag));
pi);
if (eth_macaddr_get_print_err(pi, &port->eth_addr) == 0)
- printf("Port %d: %02X:%02X:%02X:%02X:%02X:%02X\n", pi,
- 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]);
+ printf("Port %d: " RTE_ETHER_ADDR_PRT_FMT "\n", pi,
+ RTE_ETHER_ADDR_BYTES(&port->eth_addr));
/* at least one port started, need checking link status */
need_check_link_status = 1;
if (port->flow_list)
port_flow_flush(pi);
- if (rte_eth_dev_stop(pi) != 0)
+ if (eth_dev_stop_mp(pi) != 0)
RTE_LOG(ERR, EAL, "rte_eth_dev_stop failed for port %u\n",
pi);
continue;
}
- port_flow_flush(pi);
- rte_eth_dev_close(pi);
+ if (is_proc_primary()) {
+ port_flow_flush(pi);
+ rte_eth_dev_close(pi);
+ }
}
remove_invalid_ports();
}
for (i = 0 ; i < RTE_DIM(mempools) ; i++) {
if (mempools[i])
- rte_mempool_free(mempools[i]);
+ mempool_free_mp(mempools[i]);
}
printf("\nBye...\n");
* if unset do it here
*/
if ((rx_offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) == 0) {
- ret = rte_eth_dev_set_mtu(portid,
+ ret = eth_dev_set_mtu_mp(portid,
port->dev_conf.rxmode.max_rx_pkt_len - eth_overhead);
if (ret)
fprintf(stderr,
int retval;
uint16_t i;
+ if (num_procs > 1) {
+ printf("The multi-process feature doesn't support dcb.\n");
+ return -ENOTSUP;
+ }
rte_port = &ports[pid];
- memset(&port_conf, 0, sizeof(struct rte_eth_conf));
-
- port_conf.rxmode = rte_port->dev_conf.rxmode;
- port_conf.txmode = rte_port->dev_conf.txmode;
+ /* retain the original device configuration. */
+ memcpy(&port_conf, &rte_port->dev_conf, sizeof(struct rte_eth_conf));
/*set configuration of DCB in vt mode and DCB in non-vt mode*/
retval = get_eth_dcb_conf(pid, &port_conf, dcb_mode, num_tcs, pfc_en);
rte_exit(EXIT_FAILURE, "Cannot init EAL: %s\n",
rte_strerror(rte_errno));
- if (rte_eal_process_type() == RTE_PROC_SECONDARY)
- rte_exit(EXIT_FAILURE,
- "Secondary process type not supported.\n");
-
ret = register_eth_event_callback();
if (ret != 0)
rte_exit(EXIT_FAILURE, "Cannot register for ethdev events");