From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f54.google.com (mail-wm0-f54.google.com [74.125.82.54]) by dpdk.org (Postfix) with ESMTP id 30FA78E9A for ; Mon, 23 Nov 2015 15:45:20 +0100 (CET) Received: by wmec201 with SMTP id c201so164036222wme.0 for ; Mon, 23 Nov 2015 06:45:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RmeMtwMaarDHfUyd/qk4rI/jAF/YAQ8Tyaj0on0kU/o=; b=mKKkVJFAGTHHvCybCcHZnCuEiUoyqMRCROzPRYxJHCEWF3Nn0to2D9I3HvbwNl6xwY uszf4YmurGlHrQdRrrTXjYEJToWvYBFMxytAxeuxCVxfhr6qH42wuE8XEk3GU2Je2utK hs3grxqrhDL3Z+6tJlSnE1Xaazm8RA7eIghievZZXB8el/1IrxA7KV6/KruhNiuiA+vV b0f0WbFNiCzuTXln37p/Bcuv/XWEQVzt4uW7YN+XBTRAAVcCqtuL9cCjnwik3XLtHZLN 2bLAo5eyMAvoEvrfbZuJaTfBPDh84zIUCkNyNmmTM8cJZQyw9rFkV+AjpJ1DBE1zUn9r 4Q6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RmeMtwMaarDHfUyd/qk4rI/jAF/YAQ8Tyaj0on0kU/o=; b=N8oYvIO42W9uaYPSUbtZsXQ//tp3K5MmDCJEX9rfA9+xdggSxlMWTQa1pakktGu7K7 uA/BtOjZxgX2aQGd5fjLC2fttj1MJISHDlAGjICRzoNLGvaa/zIBj5ilprKuvvG1voGO O1kRiz/4y9zXgyuQSsbspLXRI0cyG2aSzPpWkwWahrePNcWL9vZ8OKgPYa5kYCRJ9zsR hCqDgA0XBq8L5Kh/okpvPtIt8ykEbzaq+lljnuVHV/x6dcdx5PWJhmq+trj03V8r7FXc SXuptkv20xOH/O0Gt/wQRDkjnlrGQxrbplH97Yn8OfcLIPI/KMo+k2v1aPFPGJAzXtlj O5UA== X-Gm-Message-State: ALoCoQngK4adPWklE8zPLl5tDZV2kW3N8wHdi7XmqVy5DV81k0r5iqfekYXKRSdw5U3dBulwqvux X-Received: by 10.194.120.226 with SMTP id lf2mr30998789wjb.108.1448289920045; Mon, 23 Nov 2015 06:45:20 -0800 (PST) Received: from 6wind.com (guy78-3-82-239-227-177.fbx.proxad.net. [82.239.227.177]) by smtp.gmail.com with ESMTPSA id cw3sm13594563wjb.26.2015.11.23.06.45.18 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 23 Nov 2015 06:45:19 -0800 (PST) From: Adrien Mazarguil To: dev@dpdk.org Date: Mon, 23 Nov 2015 15:44:37 +0100 Message-Id: <1448289889-9590-3-git-send-email-adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1448289889-9590-1-git-send-email-adrien.mazarguil@6wind.com> References: <1448289889-9590-1-git-send-email-adrien.mazarguil@6wind.com> Subject: [dpdk-dev] [PATCH 02/14] mlx4: fix memory registration for indirect mbuf data X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Nov 2015 14:45:20 -0000 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: 7fae69eeff13 ("mlx4: new poll mode driver") Signed-off-by: Jesper Wramberg Signed-off-by: Adrien Mazarguil --- drivers/net/mlx4/mlx4.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index d961a8a..f46a09e 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -985,6 +985,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. @@ -1124,7 +1142,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", @@ -1280,7 +1298,7 @@ mlx4_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