From mboxrd@z Thu Jan 1 00:00:00 1970 From: Adrien Mazarguil Subject: [PATCH 09/14] mlx5: fix memory registration for indirect mbuf data Date: Mon, 23 Nov 2015 15:44:44 +0100 Message-ID: <1448289889-9590-10-git-send-email-adrien.mazarguil@6wind.com> References: <1448289889-9590-1-git-send-email-adrien.mazarguil@6wind.com> To: dev@dpdk.org Return-path: Received: from mail-wm0-f47.google.com (mail-wm0-f47.google.com [74.125.82.47]) by dpdk.org (Postfix) with ESMTP id 4FB8991C1 for ; Mon, 23 Nov 2015 15:45:42 +0100 (CET) Received: by wmvv187 with SMTP id v187so164320098wmv.1 for ; Mon, 23 Nov 2015 06:45:42 -0800 (PST) In-Reply-To: <1448289889-9590-1-git-send-email-adrien.mazarguil@6wind.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Indirect mbuf data may come from a different mempool which must be registered separately as another memory region, otherwise such mbufs cannot be sent. Fixes: 2e22920b85d9 ("mlx5: support non-scattered Tx and Rx") Signed-off-by: Jesper Wramberg Signed-off-by: Adrien Mazarguil --- drivers/net/mlx5/mlx5_rxtx.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c index db2ac03..4c6ed32 100644 --- a/drivers/net/mlx5/mlx5_rxtx.c +++ b/drivers/net/mlx5/mlx5_rxtx.c @@ -115,6 +115,24 @@ txq_complete(struct txq *txq) } /** + * Get Memory Pool (MP) from mbuf. If mbuf is indirect, the pool from which + * the cloned mbuf is allocated is returned instead. + * + * @param buf + * Pointer to mbuf. + * + * @return + * Memory pool where data is located for given mbuf. + */ +static struct rte_mempool * +txq_mb2mp(struct rte_mbuf *buf) +{ + if (unlikely(RTE_MBUF_INDIRECT(buf))) + return rte_mbuf_from_indirect(buf)->pool; + return buf->pool; +} + +/** * Get Memory Region (MR) <-> Memory Pool (MP) association from txq->mp2mr[]. * Add MP to txq->mp2mr[] if it's not registered yet. If mp2mr[] is full, * remove an entry first. @@ -254,7 +272,7 @@ tx_burst_sg(struct txq *txq, unsigned int segs, struct txq_elt *elt, uint32_t lkey; /* Retrieve Memory Region key for this memory pool. */ - lkey = txq_mp2mr(txq, buf->pool); + lkey = txq_mp2mr(txq, txq_mb2mp(buf)); if (unlikely(lkey == (uint32_t)-1)) { /* MR does not exist. */ DEBUG("%p: unable to get MP <-> MR association", @@ -410,7 +428,7 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n) addr = rte_pktmbuf_mtod(buf, uintptr_t); length = DATA_LEN(buf); /* Retrieve Memory Region key for this memory pool. */ - lkey = txq_mp2mr(txq, buf->pool); + lkey = txq_mp2mr(txq, txq_mb2mp(buf)); if (unlikely(lkey == (uint32_t)-1)) { /* MR does not exist. */ DEBUG("%p: unable to get MP <-> MR" -- 2.1.0