From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10057.outbound.protection.outlook.com [40.107.1.57]) by dpdk.org (Postfix) with ESMTP id DFE3A1B319 for ; Mon, 30 Oct 2017 11:08:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=7qIdlMFe/G71pDJK6D9i1zNt/Z9cxklL2xrd8BGAvX8=; b=txWI/jQ/wCscV/Oi8cdWuFmcFU6D0LLmCuFRWMTjG1axfju5Rm8Mr9AH1BATE6/h68s4L4oAXxW22lPj+lvizMeS8XZx3nxuqrf4YcRjvtQ21/uBQdJcGFLyogqgo4SeKHVulbIlJsv6cYZ1s4E6IhoVuC0SpmdJH0EqfaAuVzc= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=matan@mellanox.com; Received: from mellanox.com (37.142.13.130) by VI1PR0502MB3662.eurprd05.prod.outlook.com (2603:10a6:803:f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.178.6; Mon, 30 Oct 2017 10:07:59 +0000 From: Matan Azrad To: Adrien Mazarguil Cc: dev@dpdk.org, Ophir Munk Date: Mon, 30 Oct 2017 10:07:24 +0000 Message-Id: <1509358049-18854-3-git-send-email-matan@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1509358049-18854-1-git-send-email-matan@mellanox.com> References: <1508768520-4810-1-git-send-email-ophirmu@mellanox.com> <1509358049-18854-1-git-send-email-matan@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: VI1PR08CA0217.eurprd08.prod.outlook.com (2603:10a6:802:15::26) To VI1PR0502MB3662.eurprd05.prod.outlook.com (2603:10a6:803:f::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: eea6cbe1-d114-490b-1f3f-08d51f7e1976 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(4534020)(4602075)(2017052603199); SRVR:VI1PR0502MB3662; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0502MB3662; 3:AL0hpAGbP9UKSORp5AeH9JWku6LFnQ+Ot/IvFRztiQ50CMIBgjA3Tmzg1bUwztIJXYuxFXRmwZAqn/GPLSpJWS/qxB6FTyGfEEmnUc+V9h7BPllfYOAddtUipkAVfLsY8nmz5lYhPnPTc2Bm8Pxwm49X6iq69xyzBmJ+YhezBlN04vigKGDzdDTowug/uXh7hs8ZUOv3/o/iTv0JbCagP68yVjlB5Dm0F7weMB6WkeOD86pc7kqa/9iYPulOpQc3; 25:zA1rQnKvoINtfQ9pygR2Kg4eOJgBZVCRVr3mFqk7260+i/iBxMwVzmNUgc2TPu7A4xXIL4/a6DYT2eFhZnZM06y9H2NbxXBDswc/CJknJbDBb7M4NsaE7IH2zgXDXhmdNQRG7Emj7FZ6dm1hy08BP/u9/+80XcKuDCTKzrJG/f0AywONtt9Gt2KRO1mtL2RK5a55onWVqHXP8YdCIY9mLvFdm2nfO9WSxdAr0JuSz4X39puyfzGx/ViEuKexeE7+7DIA6LLl/cAJW5JvvPq7+JRFD1ML9RSIw6WEW8+5aGeRDUMtobW+8wyB11ZJyhDhhHKqpX1gDlIk1UMH9lTJFw==; 31:2iih1irUCWRY2yk3egKA0eWGBA6qRJRxz9paLtkzL65oZbVyqKFh93qQjb+VLG9kAk38uoJfMcFUTqbflo0r3Hre/uVS6/pmTiSWOmin3sNSWnYvL42RpN4tQLPDvkpam6nPojzmG60UQBSRhdlxdWVgkrMK0jScpiyxWx9iX6kVBIXj6LSZHCIosDwh0kCGRK7C7ojvOvyi2U0Dd0f1fGpXiDXwyyi3x9XO1Mnu1vc= X-MS-TrafficTypeDiagnostic: VI1PR0502MB3662: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; VI1PR0502MB3662; 20:+01TBOyHN4WBaF5M4z6xkSZp7C30tmgm6zOr7rVS6TdViIpzmWLh5yBqjzYXdwIr54qBvwRFo5LDoB6OihIfrtvAJlRz8gflb0yDr8g4P84IsxHXmqctu19bOM+v9u1jDiMbBU+6JqC+RQ1GyIdz5Yfrsfg3UOZM4lObXwN45mM7cQ04BLQ76tZwhZjgcgeLAob1t7dxD1nZdEpX2anj2b4EygyuUS0RJlunRPEhB6kDh3Tpc4KwdvHI1kyAxBXVLDMvUVwGd7Pe7po+oebSYnsH5OUQ5Derw0Ks+Zareme1yDmC1UjSCEvQz1fHXa04e+Q9k4ohVbtt7dGa8H/DcZXqCtpzcU6ZLuw2vJ1zQ9TFhaDuILAeU5mKa38Y0r3rnRdbUkjESEHLV/WbGpOqm1qroaMXnOwd40iReZLeyPaoKYDUGMpRuGU5qUlLYH2axAJF/KwDFUFgSn1u11X0d0GoWIc4GlWkIgmoQbmcufQhrz82YRGo0xzqVOj2iOfC; 4:fGi44C+7636Iiuacw1x8FGvvirCfzgMDA6J3ilyR4NvLkU3WzEuwrmq444LDwkfPdc4g3LF1TuwIAto5S3WAc2b10uJa1KiF2kfvqIyuSWE09kpNKVnUBT2RxbX59Wq8Vw6Z7Pxgj17vTjc6Mb34/pWgJ61tUtpj11AJbDV3VkHBlC0JgZ9eXZ9c34b4U3pFAmj72Xa4Sck4OJkMGLsNxxe+XOje1wgA+61woJPLzwDSD6ReQtV9NPtv6PYMEfA6dKDljsCe0wvu60Vrvr143w== X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(3002001)(93006095)(93001095)(3231020)(10201501046)(100000703101)(100105400095)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123555025)(20161123562025)(20161123560025)(20161123564025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:VI1PR0502MB3662; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:VI1PR0502MB3662; X-Forefront-PRVS: 0476D4AB88 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(39860400002)(376002)(346002)(199003)(189002)(16526018)(97736004)(66066001)(47776003)(21086003)(5660300001)(4326008)(50226002)(316002)(53936002)(55016002)(4720700003)(6666003)(16586007)(6916009)(48376002)(36756003)(50466002)(2906002)(7736002)(305945005)(2950100002)(106356001)(101416001)(6116002)(3846002)(69596002)(68736007)(33026002)(81156014)(81166006)(8676002)(105586002)(189998001)(33646002)(107886003)(478600001)(8936002)(5003940100001)(25786009)(86362001)(575784001)(76176999)(50986999); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0502MB3662; H:mellanox.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR0502MB3662; 23:wxmv9tg5Ky7vauhG741WvVn3/B3GqwOBoZ6lNCD?= =?us-ascii?Q?c3aWyfkWYB/SHgfFsYAHo0lHjd6QvthpZnifTcP9uZT/Lwo91JhguUpB0oMO?= =?us-ascii?Q?73XvIgpzX7jIBSuu6TzuCVKcpbtvG5WTlCR5gj6jNZea4G/FO23kmKk9CFEG?= =?us-ascii?Q?jWz1Sqncykrgx6hKV6bIHGifC6BILdRWqlhnzjW3/pgSP2G6OgBKgiJTK4lr?= =?us-ascii?Q?X9Ay4nqpH46XRmcmPwQDzHn+S4EhaGYHdvjk/ZegTYeSt7PXPCU09G7xe+sW?= =?us-ascii?Q?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rg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2017 10:07:59.0523 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: eea6cbe1-d114-490b-1f3f-08d51f7e1976 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0502MB3662 Subject: [dpdk-dev] [PATCH v3 2/7] net/mlx4: associate MR to MP in a short function X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Oct 2017 10:08:01 -0000 From: Ophir Munk Associate memory region to mempool (on data path) in a short function. Handle the less common case of adding a new memory region to mempool in a separate function. Signed-off-by: Ophir Munk --- drivers/net/mlx4/mlx4.h | 2 ++ drivers/net/mlx4/mlx4_mr.c | 46 +++++++++++++++++++++++++++++++++++ drivers/net/mlx4/mlx4_rxtx.c | 57 -------------------------------------------- drivers/net/mlx4/mlx4_rxtx.h | 33 ++++++++++++++++++++++++- 4 files changed, 80 insertions(+), 58 deletions(-) diff --git a/drivers/net/mlx4/mlx4.h b/drivers/net/mlx4/mlx4.h index e0a9853..70cf453 100644 --- a/drivers/net/mlx4/mlx4.h +++ b/drivers/net/mlx4/mlx4.h @@ -160,5 +160,7 @@ int mlx4_flow_ctrl_set(struct rte_eth_dev *dev, /* mlx4_mr.c */ struct ibv_mr *mlx4_mp2mr(struct ibv_pd *pd, struct rte_mempool *mp); +uint32_t mlx4_txq_add_mr(struct txq *txq, struct rte_mempool *mp, + uint32_t i); #endif /* RTE_PMD_MLX4_H_ */ diff --git a/drivers/net/mlx4/mlx4_mr.c b/drivers/net/mlx4/mlx4_mr.c index 9700884..ebf6547 100644 --- a/drivers/net/mlx4/mlx4_mr.c +++ b/drivers/net/mlx4/mlx4_mr.c @@ -56,6 +56,7 @@ #include #include "mlx4_utils.h" +#include "mlx4_rxtx.h" struct mlx4_check_mempool_data { int ret; @@ -181,3 +182,48 @@ struct ibv_mr * rte_errno = errno ? errno : EINVAL; return mr; } + +/** + * Add memory region (MR) <-> memory pool (MP) association to txq->mp2mr[]. + * If mp2mr[] is full, remove an entry first. + * + * @param txq + * Pointer to Tx queue structure. + * @param[in] mp + * Memory pool for which a memory region lkey must be added + * @param[in] i + * Index in memory pool (MP) where to add memory region (MR) + * + * @return + * Added mr->lkey on success, (uint32_t)-1 on failure. + */ +uint32_t mlx4_txq_add_mr(struct txq *txq, struct rte_mempool *mp, uint32_t i) +{ + struct ibv_mr *mr; + + /* Add a new entry, register MR first. */ + DEBUG("%p: discovered new memory pool \"%s\" (%p)", + (void *)txq, mp->name, (void *)mp); + mr = mlx4_mp2mr(txq->priv->pd, mp); + if (unlikely(mr == NULL)) { + DEBUG("%p: unable to configure MR, ibv_reg_mr() failed.", + (void *)txq); + return (uint32_t)-1; + } + if (unlikely(i == RTE_DIM(txq->mp2mr))) { + /* Table is full, remove oldest entry. */ + DEBUG("%p: MR <-> MP table full, dropping oldest entry.", + (void *)txq); + --i; + claim_zero(ibv_dereg_mr(txq->mp2mr[0].mr)); + memmove(&txq->mp2mr[0], &txq->mp2mr[1], + (sizeof(txq->mp2mr) - sizeof(txq->mp2mr[0]))); + } + /* Store the new entry. */ + txq->mp2mr[i].mp = mp; + txq->mp2mr[i].mr = mr; + txq->mp2mr[i].lkey = mr->lkey; + DEBUG("%p: new MR lkey for MP \"%s\" (%p): 0x%08" PRIU32, + (void *)txq, mp->name, (void *)mp, txq->mp2mr[i].lkey); + return txq->mp2mr[i].lkey; +} diff --git a/drivers/net/mlx4/mlx4_rxtx.c b/drivers/net/mlx4/mlx4_rxtx.c index 4f899ff..f89df46 100644 --- a/drivers/net/mlx4/mlx4_rxtx.c +++ b/drivers/net/mlx4/mlx4_rxtx.c @@ -239,63 +239,6 @@ struct pv { } /** - * 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. - * - * @param txq - * Pointer to Tx queue structure. - * @param[in] mp - * Memory pool for which a memory region lkey must be returned. - * - * @return - * mr->lkey on success, (uint32_t)-1 on failure. - */ -uint32_t -mlx4_txq_mp2mr(struct txq *txq, struct rte_mempool *mp) -{ - unsigned int i; - struct ibv_mr *mr; - - for (i = 0; (i != RTE_DIM(txq->mp2mr)); ++i) { - if (unlikely(txq->mp2mr[i].mp == NULL)) { - /* Unknown MP, add a new MR for it. */ - break; - } - if (txq->mp2mr[i].mp == mp) { - assert(txq->mp2mr[i].lkey != (uint32_t)-1); - assert(txq->mp2mr[i].mr->lkey == txq->mp2mr[i].lkey); - return txq->mp2mr[i].lkey; - } - } - /* Add a new entry, register MR first. */ - DEBUG("%p: discovered new memory pool \"%s\" (%p)", - (void *)txq, mp->name, (void *)mp); - mr = mlx4_mp2mr(txq->priv->pd, mp); - if (unlikely(mr == NULL)) { - DEBUG("%p: unable to configure MR, ibv_reg_mr() failed.", - (void *)txq); - return (uint32_t)-1; - } - if (unlikely(i == RTE_DIM(txq->mp2mr))) { - /* Table is full, remove oldest entry. */ - DEBUG("%p: MR <-> MP table full, dropping oldest entry.", - (void *)txq); - --i; - claim_zero(ibv_dereg_mr(txq->mp2mr[0].mr)); - memmove(&txq->mp2mr[0], &txq->mp2mr[1], - (sizeof(txq->mp2mr) - sizeof(txq->mp2mr[0]))); - } - /* Store the new entry. */ - txq->mp2mr[i].mp = mp; - txq->mp2mr[i].mr = mr; - txq->mp2mr[i].lkey = mr->lkey; - DEBUG("%p: new MR lkey for MP \"%s\" (%p): 0x%08" PRIu32, - (void *)txq, mp->name, (void *)mp, txq->mp2mr[i].lkey); - return txq->mp2mr[i].lkey; -} - -/** * Posts a single work request to a send queue. * * @param txq diff --git a/drivers/net/mlx4/mlx4_rxtx.h b/drivers/net/mlx4/mlx4_rxtx.h index 7d67748..b32fcc9 100644 --- a/drivers/net/mlx4/mlx4_rxtx.h +++ b/drivers/net/mlx4/mlx4_rxtx.h @@ -36,6 +36,7 @@ #include #include +#include /* Verbs headers do not support -pedantic. */ #ifdef PEDANTIC @@ -165,7 +166,6 @@ int mlx4_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, /* mlx4_rxtx.c */ -uint32_t mlx4_txq_mp2mr(struct txq *txq, struct rte_mempool *mp); uint16_t mlx4_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n); uint16_t mlx4_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, @@ -182,4 +182,35 @@ int mlx4_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, const struct rte_eth_txconf *conf); void mlx4_tx_queue_release(void *dpdk_txq); + +/** + * Get memory region (MR) <-> memory pool (MP) association from txq->mp2mr[]. + * Call mlx4_txq_add_mr() if MP is not registered yet. + * + * @param txq + * Pointer to Tx queue structure. + * @param[in] mp + * Memory pool for which a memory region lkey must be returned. + * + * @return + * mr->lkey on success, (uint32_t)-1 on failure. + */ +static inline uint32_t +mlx4_txq_mp2mr(struct txq *txq, struct rte_mempool *mp) +{ + unsigned int i; + + for (i = 0; (i != RTE_DIM(txq->mp2mr)); ++i) { + if (unlikely(txq->mp2mr[i].mp == NULL)) { + /* Unknown MP, add a new MR for it. */ + break; + } + if (txq->mp2mr[i].mp == mp) { + assert(txq->mp2mr[i].lkey != (uint32_t)-1); + assert(txq->mp2mr[i].mr->lkey == txq->mp2mr[i].lkey); + return txq->mp2mr[i].lkey; + } + } + return mlx4_txq_add_mr(txq, mp, i); +} #endif /* MLX4_RXTX_H_ */ -- 1.8.3.1