summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFerruh Yigit <ferruh.yigit@intel.com>2016-06-01 15:37:23 +0100
committerFerruh Yigit <ferruh.yigit@intel.com>2016-07-27 13:50:33 +0100
commitc52a7cd536a8bff0b9177625ea1602dfaaca6e78 (patch)
treeb6a05c91279ec5c4a6f3a8ca943fa1b0644f4400
parentf761fd570cc3059f1577e62b291622214f8d78cf (diff)
downloadspp-c52a7cd536a8bff0b9177625ea1602dfaaca6e78.zip
spp-c52a7cd536a8bff0b9177625ea1602dfaaca6e78.tar.gz
spp-c52a7cd536a8bff0b9177625ea1602dfaaca6e78.tar.xz
spp_vm: make ring->memzone accessible
rte_eth_from_ring() uses ring->memzone->socket_id field, but this field is not accessible for spp_vm. There was a workaround to set ring->memzone to NULL and force ring pmd set SOCKEY_ANY. ring->memzone made accessible and workaround removed. 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/main.c38
1 files changed, 30 insertions, 8 deletions
diff --git a/examples/multi_process/patch_panel/vm/main.c b/examples/multi_process/patch_panel/vm/main.c
index eaf53df..5a3c57b 100644
--- a/examples/multi_process/patch_panel/vm/main.c
+++ b/examples/multi_process/patch_panel/vm/main.c
@@ -33,7 +33,9 @@
#include <arpa/inet.h>
+#include <rte_eal_memconfig.h>
#include <rte_eth_ring.h>
+#include <rte_memzone.h>
#include "args.h"
#include "common.h"
@@ -345,6 +347,29 @@ add_patch(int in_port, int out_port)
return 0;
}
+static struct rte_memzone *
+get_memzone_by_addr(const void *addr)
+{
+ struct rte_memzone *tmp, *mz;
+ struct rte_mem_config *mcfg;
+ int i;
+
+ mcfg = rte_eal_get_configuration()->mem_config;
+ mz = NULL;
+
+ /* find memzone for the ring */
+ for (i = 0; i < RTE_MAX_MEMZONE; i++) {
+ tmp = &mcfg->memzone[i];
+
+ if (tmp->addr_64 == (uint64_t) addr) {
+ mz = tmp;
+ break;
+ }
+ }
+
+ return mz;
+}
+
static int
add_ring_pmd(int ring_id)
{
@@ -360,16 +385,13 @@ add_ring_pmd(int ring_id)
return -1;
}
+ memzone = get_memzone_by_addr(ring);
+ if (memzone == NULL)
+ return -1;
+
/* create ring pmd*/
- /*
- * TODO: ring->memzone is not accessable by vm
- * this is workaround to prevent a crash in vm,
- * this should be fixed properly
- */
- memzone = ring->memzone;
- ring->memzone = NULL;
- ring_port_id = rte_eth_from_ring(ring);
ring->memzone = memzone;
+ ring_port_id = rte_eth_from_ring(ring);
RTE_LOG(DEBUG, APP, "ring port id %d\n", ring_port_id);