/*-
* 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
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * version: DPDK.L.1.2.3-3
*/
#include <stdint.h>
#include <rte_ether.h>
#include <rte_ethdev.h>
#include <rte_malloc.h>
-#include <rte_hash_crc.h>
#include <rte_fbk_hash.h>
#include <rte_string_fns.h>
+#include <rte_cycles.h>
#include "common.h"
#include "init_drivers.h"
pktmbuf_pool = rte_mempool_create(PKTMBUF_POOL_NAME, num_mbufs,
MBUF_SIZE, MBUF_CACHE_SIZE,
sizeof(struct rte_pktmbuf_pool_private), rte_pktmbuf_pool_init,
- NULL, rte_pktmbuf_init, NULL, SOCKET0, NO_FLAGS );
+ NULL, rte_pktmbuf_init, NULL, rte_socket_id(), NO_FLAGS );
return (pktmbuf_pool == NULL); /* 0 on success */
}
/* for port configuration all features are off by default */
const struct rte_eth_conf port_conf = {
.rxmode = {
- .mq_mode = ETH_RSS
+ .mq_mode = ETH_MQ_RX_RSS
}
};
const uint16_t rx_rings = 1, tx_rings = num_clients;
const uint16_t rx_ring_size = RTE_MP_RX_DESC_DEFAULT;
const uint16_t tx_ring_size = RTE_MP_TX_DESC_DEFAULT;
- struct rte_eth_link link;
uint16_t q;
int retval;
for (q = 0; q < rx_rings; q++) {
retval = rte_eth_rx_queue_setup(port_num, q, rx_ring_size,
- SOCKET0, &rx_conf_default, pktmbuf_pool);
+ rte_eth_dev_socket_id(port_num), &rx_conf_default, pktmbuf_pool);
if (retval < 0) return retval;
}
for ( q = 0; q < tx_rings; q ++ ) {
retval = rte_eth_tx_queue_setup(port_num, q, tx_ring_size,
- SOCKET0, &tx_conf_default);
+ rte_eth_dev_socket_id(port_num), &tx_conf_default);
if (retval < 0) return retval;
}
retval = rte_eth_dev_start(port_num);
if (retval < 0) return retval;
- printf( "done: ");
+ printf( "done: \n");
- /* get link status */
- rte_eth_link_get(port_num, &link);
- if (link.link_status) {
- printf(" Link Up - speed %u Mbps - %s\n",
- (uint32_t) link.link_speed,
- (link.link_duplex == ETH_LINK_FULL_DUPLEX) ?
- ("full-duplex") : ("half-duplex\n"));
- }
- else{
- printf(" Link Down\n");
- }
return 0;
}
init_shm_rings(void)
{
unsigned i;
+ unsigned socket_id;
+ const char * q_name;
const unsigned ringsize = CLIENT_QUEUE_RINGSIZE;
clients = rte_malloc("client details",
for (i = 0; i < num_clients; i++) {
/* Create an RX queue for each client */
- clients[i].rx_q = rte_ring_create(get_rx_queue_name(i),
- ringsize, SOCKET0,
+ socket_id = rte_socket_id();
+ q_name = get_rx_queue_name(i);
+ clients[i].rx_q = rte_ring_create(q_name,
+ ringsize, socket_id,
RING_F_SP_ENQ | RING_F_SC_DEQ ); /* single prod, single cons */
if (clients[i].rx_q == NULL)
rte_exit(EXIT_FAILURE, "Cannot create rx ring queue for client %u\n", i);
return 0;
}
+/* Check the link status of all ports in up to 9s, and print them finally */
+static void
+check_all_ports_link_status(uint8_t port_num, uint32_t port_mask)
+{
+#define CHECK_INTERVAL 100 /* 100ms */
+#define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */
+ uint8_t portid, count, all_ports_up, print_flag = 0;
+ struct rte_eth_link link;
+
+ printf("\nChecking link status");
+ fflush(stdout);
+ for (count = 0; count <= MAX_CHECK_TIME; count++) {
+ all_ports_up = 1;
+ for (portid = 0; portid < port_num; portid++) {
+ if ((port_mask & (1 << portid)) == 0)
+ continue;
+ memset(&link, 0, sizeof(link));
+ rte_eth_link_get_nowait(portid, &link);
+ /* print link status if flag set */
+ if (print_flag == 1) {
+ if (link.link_status)
+ printf("Port %d Link Up - speed %u "
+ "Mbps - %s\n", (uint8_t)portid,
+ (unsigned)link.link_speed,
+ (link.link_duplex == ETH_LINK_FULL_DUPLEX) ?
+ ("full-duplex") : ("half-duplex\n"));
+ else
+ printf("Port %d Link Down\n",
+ (uint8_t)portid);
+ continue;
+ }
+ /* clear all_ports_up flag if any link down */
+ if (link.link_status == 0) {
+ all_ports_up = 0;
+ break;
+ }
+ }
+ /* after finally printing all link status, get out */
+ if (print_flag == 1)
+ break;
+
+ if (all_ports_up == 0) {
+ printf(".");
+ fflush(stdout);
+ rte_delay_ms(CHECK_INTERVAL);
+ }
+
+ /* set the print_flag if all ports up or timeout */
+ if (all_ports_up == 1 || count == (MAX_CHECK_TIME - 1)) {
+ print_flag = 1;
+ printf("done\n");
+ }
+ }
+}
+
/**
* Main init function for the multi-process server app,
* calls subfunctions to do each stage of the initialisation.
(unsigned)i);
}
+ check_all_ports_link_status(ports->num_ports, (~0x0));
+
/* initialise the client queues/rings for inter-eu comms */
init_shm_rings();