/*-
* BSD LICENSE
*
- * Copyright(c) 2010-2012 Intel Corporation. All rights reserved.
+ * Copyright(c) 2010-2013 Intel Corporation. All rights reserved.
* All rights reserved.
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
* are met:
*
- * * Redistributions of source code must retain the above copyright
+ * * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
* distribution.
- * * Neither the name of Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
+ * * Neither the name of Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
*/
#include <stdarg.h>
*/
uint8_t numa_support = 0; /**< No numa support by default */
+/*
+ * In UMA mode,all memory is allocated from socket 0 if --socket-num is
+ * not configured.
+ */
+uint8_t socket_num = UMA_NO_CONFIG;
+
/*
* Record the Ethernet address of peer target ports to which packets are
* forwarded.
struct rte_mempool *mbp;
unsigned int nb_mbuf_per_pool;
lcoreid_t lc_id;
+ uint8_t port_per_socket[MAX_SOCKET];
+ memset(port_per_socket,0,MAX_SOCKET);
/* Configuration of logical cores. */
fwd_lcores = rte_zmalloc("testpmd: fwd_lcores",
sizeof(struct fwd_lcore *) * nb_lcores,
/*
* Create pools of mbuf.
* If NUMA support is disabled, create a single pool of mbuf in
- * socket 0 memory.
+ * socket 0 memory by default.
* Otherwise, create a pool of mbuf in the memory of sockets 0 and 1.
*
* Use the maximum value of nb_rxd and nb_txd here, then nb_rxd and
* nb_txd can be configured at run time.
*/
- if (param_total_num_mbufs)
+ if (param_total_num_mbufs)
nb_mbuf_per_pool = param_total_num_mbufs;
else {
nb_mbuf_per_pool = RTE_TEST_RX_DESC_MAX + (nb_lcores * mb_mempool_cache)
+ RTE_TEST_TX_DESC_MAX + MAX_PKT_BURST;
- nb_mbuf_per_pool = (nb_mbuf_per_pool * nb_ports);
- }
- if (numa_support) {
- nb_mbuf_per_pool /= 2;
- mbuf_pool_create(mbuf_data_size, nb_mbuf_per_pool, 0);
- mbuf_pool_create(mbuf_data_size, nb_mbuf_per_pool, 1);
- } else {
- mbuf_pool_create(mbuf_data_size, nb_mbuf_per_pool, 0);
+
+ if (!numa_support)
+ nb_mbuf_per_pool = (nb_mbuf_per_pool * nb_ports);
}
+ if (!numa_support) {
+ if (socket_num == UMA_NO_CONFIG)
+ mbuf_pool_create(mbuf_data_size, nb_mbuf_per_pool, 0);
+ else
+ mbuf_pool_create(mbuf_data_size, nb_mbuf_per_pool,
+ socket_num);
+ }
/*
* Records which Mbuf pool to use by each logical core, if needed.
*/
rte_exit(EXIT_FAILURE, "rte_zmalloc(%d struct rte_port) "
"failed\n", nb_ports);
}
-
+
for (pid = 0; pid < nb_ports; pid++) {
port = &ports[pid];
rte_eth_dev_info_get(pid, &port->dev_info);
+ 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);
+ port_per_socket[socket_id]++;
+ }
+ }
+
/* set flag to initialize port/queue */
port->need_reconfig = 1;
port->need_reconfig_queues = 1;
}
+ if (numa_support) {
+ uint8_t i;
+ unsigned int nb_mbuf;
+
+ if (param_total_num_mbufs)
+ nb_mbuf_per_pool = nb_mbuf_per_pool/nb_ports;
+
+ for (i = 0; i < MAX_SOCKET; i++) {
+ nb_mbuf = (nb_mbuf_per_pool *
+ port_per_socket[i]);
+ if (nb_mbuf)
+ mbuf_pool_create(mbuf_data_size,
+ nb_mbuf,i);
+ }
+ }
init_port_config();
-
/* Configuration of packet forwarding streams. */
if (init_fwd_streams() < 0)
rte_exit(EXIT_FAILURE, "FAIL from init_fwd_streams()\n");
port->dev_info.max_tx_queues);
return -1;
}
- if (numa_support)
- port->socket_id = (pid < (nb_ports >> 1)) ? 0 : 1;
- else
- port->socket_id = 0;
+ if (numa_support)
+ port->socket_id = rte_eth_dev_socket_id(pid);
+ else {
+ if (socket_num == UMA_NO_CONFIG)
+ port->socket_id = 0;
+ else
+ port->socket_id = socket_num;
+ }
}
nb_fwd_streams_new = (streamid_t)(nb_ports * nb_rxq);
if (port->need_reconfig > 0) {
port->need_reconfig = 0;
- printf("Configuring Port %d\n", pi);
+ printf("Configuring Port %d (socket %d)\n", pi,
+ rte_eth_dev_socket_id(pi));
/* configure port */
diag = rte_eth_dev_configure(pi, nb_rxq, nb_txq,
&(port->dev_conf));
return;
}
}
-
if (port->need_reconfig_queues > 0) {
port->need_reconfig_queues = 0;
-
/* setup tx queues */
for (qi = 0; qi < nb_txq; qi++) {
- diag = rte_eth_tx_queue_setup(pi, qi, nb_txd,
- port->socket_id, &(port->tx_conf));
+ if ((numa_support) &&
+ (txring_numa[pi] != NUMA_NO_CONFIG))
+ diag = rte_eth_tx_queue_setup(pi, qi,
+ nb_txd,txring_numa[pi],
+ &(port->tx_conf));
+ else
+ diag = rte_eth_tx_queue_setup(pi, qi,
+ nb_txd,port->socket_id,
+ &(port->tx_conf));
+
if (diag == 0)
continue;
}
/* setup rx queues */
for (qi = 0; qi < nb_rxq; qi++) {
- diag = rte_eth_rx_queue_setup(pi, qi, nb_rxd,
- port->socket_id, &(port->rx_conf),
- mbuf_pool_find(port->socket_id));
+ if ((numa_support) &&
+ (rxring_numa[pi] != NUMA_NO_CONFIG)) {
+ struct rte_mempool * mp =
+ mbuf_pool_find(rxring_numa[pi]);
+ if (mp == NULL) {
+ printf("Failed to setup RX queue:"
+ "No mempool allocation"
+ "on the socket %d\n",
+ rxring_numa[pi]);
+ return;
+ }
+
+ diag = rte_eth_rx_queue_setup(pi, qi,
+ nb_rxd,rxring_numa[pi],
+ &(port->rx_conf),mp);
+ }
+ else
+ diag = rte_eth_rx_queue_setup(pi, qi,
+ nb_rxd,port->socket_id,
+ &(port->rx_conf),
+ mbuf_pool_find(port->socket_id));
+
if (diag == 0)
continue;
+
/* Fail to setup rx queue, return */
if (rte_atomic16_cmpset(&(port->port_status),
RTE_PORT_HANDLING,
return;
}
}
-
/* start port */
if (rte_eth_dev_start(pi) < 0) {
printf("Fail to start port %d\n", pi);
}
/*set DCB mode of RX and TX of multiple queues*/
- eth_conf->rxmode.mq_mode = ETH_VMDQ_DCB;
- eth_conf->txmode.mq_mode = ETH_VMDQ_DCB_TX;
+ eth_conf->rxmode.mq_mode = ETH_MQ_RX_VMDQ_DCB;
+ eth_conf->txmode.mq_mode = ETH_MQ_TX_VMDQ_DCB;
if (dcb_conf->pfc_en)
eth_conf->dcb_capability_en = ETH_DCB_PG_SUPPORT|ETH_DCB_PFC_SUPPORT;
else
rx_conf.dcb_queue[i] = i;
tx_conf.dcb_queue[i] = i;
}
- eth_conf->rxmode.mq_mode = ETH_DCB_RX;
- eth_conf->txmode.mq_mode = ETH_DCB_TX;
+ eth_conf->rxmode.mq_mode = ETH_MQ_RX_DCB;
+ eth_conf->txmode.mq_mode = ETH_MQ_TX_DCB;
if (dcb_conf->pfc_en)
eth_conf->dcb_capability_en = ETH_DCB_PG_SUPPORT|ETH_DCB_PFC_SUPPORT;
else