diff mbox series

[v1,1/3] linux-gen: pktio: ipc fix packets free

Message ID 1499716806-18707-2-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [v1,1/3] linux-gen: pktio: ipc fix packets free | expand

Commit Message

Github ODP bot July 10, 2017, 8 p.m. UTC
From: Maxim Uvarov <maxim.uvarov@linaro.org>


Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>

---
/** Email created from pull request 72 (muvarov:master_ipc_pkt_free_fix)
 ** https://github.com/Linaro/odp/pull/72
 ** Patch: https://github.com/Linaro/odp/pull/72.patch
 ** Base sha: 5a2ed3eefb1a263139282c376741adb2c355bd5a
 ** Merge commit sha: 5853863d527ef327a244740d931cd2d0fb05db5f
 **/
 platform/linux-generic/pktio/ipc.c | 31 ++++++++++++++++++++++++++-----
 1 file changed, 26 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/platform/linux-generic/pktio/ipc.c b/platform/linux-generic/pktio/ipc.c
index 54e42227..f0facd8c 100644
--- a/platform/linux-generic/pktio/ipc.c
+++ b/platform/linux-generic/pktio/ipc.c
@@ -389,10 +389,15 @@  static void _ipc_free_ring_packets(pktio_entry_t *pktio_entry, _ring_t *r)
 	int ret;
 	void **rbuf_p;
 	int i;
+	void *addr;
+	pool_t *pool;
 
 	if (!r)
 		return;
 
+	pool = pool_entry_from_hdl(pktio_entry->s.ipc.pool);
+	addr = odp_shm_addr(pool->shm);
+
 	rbuf_p = (void *)&offsets;
 
 	while (1) {
@@ -403,10 +408,10 @@  static void _ipc_free_ring_packets(pktio_entry_t *pktio_entry, _ring_t *r)
 		for (i = 0; i < ret; i++) {
 			odp_packet_hdr_t *phdr;
 			odp_packet_t pkt;
-			void *mbase = pktio_entry->s.ipc.pool_mdata_base;
 
-			phdr = (void *)((uint8_t *)mbase + offsets[i]);
+			phdr = (void *)((uint8_t *)addr + offsets[i]);
 			pkt = packet_handle(phdr);
+
 			odp_packet_free(pkt);
 		}
 	}
@@ -420,7 +425,7 @@  static int ipc_pktio_recv_lockless(pktio_entry_t *pktio_entry,
 	_ring_t *r;
 	_ring_t *r_p;
 	uintptr_t offsets[PKTIO_IPC_ENTRIES];
-	void **ipcbufs_p = (void *)&offsets;
+	void **ipcbufs_p = (void *)&offsets[0];
 	uint32_t ready;
 	int pkts_ring;
 
@@ -437,6 +442,11 @@  static int ipc_pktio_recv_lockless(pktio_entry_t *pktio_entry,
 	if (odp_unlikely(pkts < 0))
 		ODP_ABORT("internal error dequeue\n");
 
+	for (i = 0; i < pkts; i++) {
+		IPC_ODP_DBG("%d/%d recv packet offset %x\n",
+			    i, pkts, offsets[i]);
+	}
+
 	/* fast path */
 	if (odp_likely(0 == pkts))
 		return 0;
@@ -511,9 +521,17 @@  static int ipc_pktio_recv_lockless(pktio_entry_t *pktio_entry,
 	r_p = pktio_entry->s.ipc.rx.free;
 
 repeat:
+
+	ipcbufs_p = (void *)&offsets[0];
 	pkts_ring = _ring_mp_enqueue_burst(r_p, ipcbufs_p, pkts);
 	if (odp_unlikely(pkts_ring < 0))
 		ODP_ABORT("ipc: odp_ring_mp_enqueue_bulk r_p fail\n");
+
+	for (i = 0; i < pkts; i++) {
+		IPC_ODP_DBG("%d/%d send to be free packet offset %x\n",
+			    i, pkts, offsets[i]);
+	}
+
 	if (odp_unlikely(pkts != pkts_ring)) {
 		IPC_ODP_DBG("odp_ring_full: %d, odp_ring_count %d,"
 			    " _ring_free_count %d\n",
@@ -597,10 +615,13 @@  static int ipc_pktio_send_lockless(pktio_entry_t *pktio_entry,
 		/* compile all function code even if ipc disabled with config */
 		pkt_hdr->buf_hdr.ipc_data_offset = data_pool_off;
 		IPC_ODP_DBG("%d/%d send packet %llx, pool %llx,"
-			    "phdr = %p, offset %x\n",
+			    "phdr = %p, offset %x sendoff %x, addr %llx iaddr %llx\n",
 			    i, len,
 			    odp_packet_to_u64(pkt), odp_pool_to_u64(pool_hdl),
-			    pkt_hdr, pkt_hdr->buf_hdr.ipc_data_offset);
+			    pkt_hdr, pkt_hdr->buf_hdr.ipc_data_offset,
+			    offsets[i], odp_shm_addr(pool->shm),
+			    odp_shm_addr(pool_entry_from_hdl(
+					 pktio_entry->s.ipc.pool)->shm));
 	}
 
 	/* Put packets to ring to be processed by other process. */