app/testpmd: fix vdev socket initialization

The cmdline settings of port-numa-config and rxring-numa-config have
been flushed by the following init_config. If we don't configure the
port-numa-config, the virtual device will allocate the device ports to
socket 0. It will cause failure when the socket 0 is unavailable.

eg:
testpmd -l <cores from socket 1> --vdev net_pcap0,iface=lo
--socket-mem=64 -- --numa --port-numa-config="(0,1)"
--ring-numa-config="(0,1,1),(0,2,1)" -i

...
Configuring Port 0 (socket 0)
Failed to setup RX queue:No mempool allocation on the socket 0
EAL: Error - exiting with code: 1
  Cause: Start ports failed

Fix by allocate the devices port to the first available socket or the
socket configured in port-numa-config.

Fixes: 487f9a592a27 ("app/testpmd: fix NUMA structures initialization")
Fixes: 20a0286fd2c0 ("app/testpmd: check socket id validity")
Cc: stable@dpdk.org

Signed-off-by: Phil Yang <phil.yang@arm.com>
Reviewed-by: Gavin Hu <gavin.hu@arm.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
This commit is contained in:
Phil Yang 2018-10-12 17:34:55 +08:00 committed by Ferruh Yigit
parent dcf3d57fa4
commit 2984133643

View File

@ -1021,12 +1021,6 @@ init_config(void)
memset(port_per_socket,0,RTE_MAX_NUMA_NODES); memset(port_per_socket,0,RTE_MAX_NUMA_NODES);
if (numa_support) {
memset(port_numa, NUMA_NO_CONFIG, RTE_MAX_ETHPORTS);
memset(rxring_numa, NUMA_NO_CONFIG, RTE_MAX_ETHPORTS);
memset(txring_numa, NUMA_NO_CONFIG, RTE_MAX_ETHPORTS);
}
/* Configuration of logical cores. */ /* Configuration of logical cores. */
fwd_lcores = rte_zmalloc("testpmd: fwd_lcores", fwd_lcores = rte_zmalloc("testpmd: fwd_lcores",
sizeof(struct fwd_lcore *) * nb_lcores, sizeof(struct fwd_lcore *) * nb_lcores,
@ -1063,9 +1057,12 @@ init_config(void)
else { else {
uint32_t socket_id = rte_eth_dev_socket_id(pid); uint32_t socket_id = rte_eth_dev_socket_id(pid);
/* if socket_id is invalid, set to 0 */ /*
* if socket_id is invalid,
* set to the first available socket.
*/
if (check_socket_id(socket_id) < 0) if (check_socket_id(socket_id) < 0)
socket_id = 0; socket_id = socket_ids[0];
port_per_socket[socket_id]++; port_per_socket[socket_id]++;
} }
} }
@ -1221,9 +1218,12 @@ init_fwd_streams(void)
else { else {
port->socket_id = rte_eth_dev_socket_id(pid); port->socket_id = rte_eth_dev_socket_id(pid);
/* if socket_id is invalid, set to 0 */ /*
* if socket_id is invalid,
* set to the first available socket.
*/
if (check_socket_id(port->socket_id) < 0) if (check_socket_id(port->socket_id) < 0)
port->socket_id = 0; port->socket_id = socket_ids[0];
} }
} }
else { else {
@ -2294,9 +2294,9 @@ attach_port(char *identifier)
return; return;
socket_id = (unsigned)rte_eth_dev_socket_id(pi); socket_id = (unsigned)rte_eth_dev_socket_id(pi);
/* if socket_id is invalid, set to 0 */ /* if socket_id is invalid, set to the first available socket. */
if (check_socket_id(socket_id) < 0) if (check_socket_id(socket_id) < 0)
socket_id = 0; socket_id = socket_ids[0];
reconfig(pi, socket_id); reconfig(pi, socket_id);
rte_eth_promiscuous_enable(pi); rte_eth_promiscuous_enable(pi);
@ -2954,6 +2954,11 @@ init_port(void)
"rte_zmalloc(%d struct rte_port) failed\n", "rte_zmalloc(%d struct rte_port) failed\n",
RTE_MAX_ETHPORTS); RTE_MAX_ETHPORTS);
} }
/* Initialize ports NUMA structures */
memset(port_numa, NUMA_NO_CONFIG, RTE_MAX_ETHPORTS);
memset(rxring_numa, NUMA_NO_CONFIG, RTE_MAX_ETHPORTS);
memset(txring_numa, NUMA_NO_CONFIG, RTE_MAX_ETHPORTS);
} }
static void static void