summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFerruh Yigit <ferruh.yigit@intel.com>2016-06-01 16:43:31 +0100
committerFerruh Yigit <ferruh.yigit@intel.com>2016-07-27 13:50:45 +0100
commitc52c9f9e9a054c13a39d6c4960a68c401ec2914e (patch)
treec8923b7ff0f706e48d66f4f7b159a2b7a09ef340
parentcf92112277ca234964f7bbbfdb7ca732c503068c (diff)
downloadspp-c52c9f9e9a054c13a39d6c4960a68c401ec2914e.zip
spp-c52c9f9e9a054c13a39d6c4960a68c401ec2914e.tar.gz
spp-c52c9f9e9a054c13a39d6c4960a68c401ec2914e.tar.xz
spp_vm: get and use shared port info
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com> Acked-by: Sy Jong Choi <sy.jong.choi@intel.com>
-rw-r--r--examples/multi_process/patch_panel/vm/init.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/examples/multi_process/patch_panel/vm/init.c b/examples/multi_process/patch_panel/vm/init.c
index fc444d7..9d8a5f9 100644
--- a/examples/multi_process/patch_panel/vm/init.c
+++ b/examples/multi_process/patch_panel/vm/init.c
@@ -52,10 +52,10 @@ struct port_info *ports;
* buffer pools needed by the app - currently none.
*/
static int
-init_mbuf_pools(void)
+init_mbuf_pools(int total_ports)
{
const unsigned int num_mbufs = (num_clients * MBUFS_PER_CLIENT)
- + (ports->num_ports * MBUFS_PER_PORT);
+ + (total_ports * MBUFS_PER_PORT);
/*
* don't pass single-producer/single-consumer flags to mbuf create as
@@ -103,21 +103,17 @@ init(int argc, char *argv[])
total_ports = rte_eth_dev_count();
/* set up array for port data */
- if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
- mz = rte_memzone_lookup(VM_MZ_PORT_INFO);
- if (mz == NULL)
- rte_exit(EXIT_FAILURE,
- "Cannot get port info structure\n");
- ports = mz->addr;
- } else {
- mz = rte_memzone_reserve(VM_MZ_PORT_INFO, sizeof(*ports),
+ mz = rte_memzone_lookup(MZ_PORT_INFO);
+ if (mz == NULL) {
+ RTE_LOG(DEBUG, APP, "Cannot get port info structure\n");
+ mz = rte_memzone_reserve(MZ_PORT_INFO, sizeof(*ports),
rte_socket_id(), NO_FLAGS);
if (mz == NULL)
rte_exit(EXIT_FAILURE,
"Cannot reserve memory zone for port information\n");
memset(mz->addr, 0, sizeof(*ports));
- ports = mz->addr;
}
+ ports = mz->addr;
/* parse additional, application arguments */
retval = parse_app_args(total_ports, argc, argv);
@@ -125,20 +121,20 @@ init(int argc, char *argv[])
return -1;
/* initialise mbuf pools */
- retval = init_mbuf_pools();
+ retval = init_mbuf_pools(total_ports);
if (retval != 0)
rte_exit(EXIT_FAILURE, "Cannot create needed mbuf pools\n");
/* now initialise the ports we will use */
if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
- for (i = 0; i < ports->num_ports; i++) {
+ for (i = 0; i < total_ports; i++) {
retval = init_port(ports->id[i], pktmbuf_pool);
if (retval != 0)
rte_exit(EXIT_FAILURE,
"Cannot initialise port %d\n", i);
}
}
- check_all_ports_link_status(ports, ports->num_ports, (~0x0));
+ check_all_ports_link_status(ports, total_ports, (~0x0));
return 0;
}