From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0045.outbound.protection.outlook.com [104.47.0.45]) by dpdk.org (Postfix) with ESMTP id BAD891B25C for ; Tue, 31 Oct 2017 19:21:56 +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=/3jxJBbGlCvOFKT3yO09nRZakO1rXbxFM5gVbLeeTC4=; b=omPi/VpWBkeLa+QI3PMsHLjW+HlHnah9UfF8z0k+oonREDnyMMb46QC8o9pDLt0beNd5aa1W1y7lyl4+hA3AwBKeD0KPK/GbQCDdvlHB2XBuRXeU2kEP0m2b+nVHfY48U0p+EgRy033JrtoscS+eX7MAlz9h1VePZzgq5f+ipqU= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=matan@mellanox.com; Received: from mellanox.com (37.142.13.130) by VI1PR0502MB3664.eurprd05.prod.outlook.com (2603:10a6:803:f::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.178.6; Tue, 31 Oct 2017 18:21:54 +0000 From: Matan Azrad To: Adrien Mazarguil Cc: dev@dpdk.org, Ophir Munk Date: Tue, 31 Oct 2017 18:21:27 +0000 Message-Id: <1509474093-31388-3-git-send-email-matan@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1509474093-31388-1-git-send-email-matan@mellanox.com> References: <1509358049-18854-1-git-send-email-matan@mellanox.com> <1509474093-31388-1-git-send-email-matan@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: VI1PR0801CA0074.eurprd08.prod.outlook.com (2603:10a6:800:7d::18) To VI1PR0502MB3664.eurprd05.prod.outlook.com (2603:10a6:803:f::23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 950f528f-0139-4abd-5ba8-08d5208c440b X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(4534020)(4602075)(2017052603199); SRVR:VI1PR0502MB3664; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0502MB3664; 3:FMnqvGqsK8KEII9a6unIhb0nB0zWM+OSvAkX4SfXLbz3tl0WCEHfxdOwd5xrv1dt7K8MjcyrWlyPoX+T2pEFJuY5lrhmFLNJoVVGTSbSO4YVajlnplIpgLlBLj8zbTnn7I1Xb98NNRqhFnGo6eqoi4hZUq9Hhugz4tDFSQHZ+U8ILhkQaKzuicSLR/Z+y6Y/qnUTQcxg06C0ybsPqrP/sC/d7M2Rlvuli9hsDJ7v2u9hPLozMJ5ynxHAvNbhdDc4; 25:8qpmaeEQWtOrgCfplIfFP3n1nSA1/cJO8L9BpNl/xtHJSuCUlj1Pry3/yL7WyUkIj7AY7DBWdPSZ7wg+gyVKlJsYD+Gz8GY6l+mcPRPR4C4zHU+Km8YZwh59tMDK8yyQUIREPKhbD+dFpPEUMMxjHYc696KQGCVtjWySjifamZBsMCKCkEHuEwh2vmcwDf3uUTOKlLVqx6+8ieFaUmirg8MzvScYNUrPYWbcmHR3seg8Bpr752p2qFBcyvE2uDSHMh4co/dsH6YzRKa7/3RDFIXVdQtL0HIfgArnboLrfFySwfcunHWhvkNJQ0ulL+Tkk/DCT0nzG/8cKO7QCQOeRg==; 31:2TjsbArrWtG2Whise/+rjlF5HResUcJrAXlB5BQe0gFpCCjb0ddJYmpVtS4a4WA0OLl8Tb9Src08Jy+tCDgQvpBX/OeUd+LE7RPQwPSBWusgSGTTu6sDfrU4BRK8Y5oEVvkEonkQ4UBHMvdsKxDtVIG8yCO/4/NgNdeO2E2bCIgRGHHd/D++uPNfmKSTxLyL/ZzEJeOpcPDW86TRXlx5IDeFyix6BYCH9eVhzUBYs1M= X-MS-TrafficTypeDiagnostic: VI1PR0502MB3664: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; VI1PR0502MB3664; 20:JCQcfGTnIN9lW9W/y4mJtENVdZFxqcWl6NZD7fzvB8iCMwUmWVOl82AbLaM4r1s+T311Rlg5Fh6drBo8TDLNfEaQ/oEZtPz4Zp3qxp0+w+zOL8pl6Zl6+JWj/xW+jloodCyJyTqhoyL9evHt9E0zr0smKuiE2uP1sM5bPoZvbfaUKtSUWKdVH1VVbeL9JNWlZMNf/oB9H0Ou6cdhu669y9ejJG9/cc/fsyJNuIUaOeF0UbbnhGgfmNuH425YhkCvikR+gezDmPq9fZY2I9ByhE+6xdzMaBFlVk345gtJ4FT81Nc3g/AsutVkEM3uHzHnaipRLzlT0+CUBxgU5z2Jpmgc3VQU3XBOhIDHZKu8Ifkw6Ysozc2N5EW6bszHxDiUChYTXkGpoiEZ9iZpsyhWO9SuuGHepNpMuCJ/RzhUJr8EEzFX5IVyjuvQ9/Q8AHd7eH/2ob01l5/rYljfsiNGqKcczz9GU/8xu41zrpQfYktydEeSaxdCB4WUZhF6a3fL; 4:oAXS2jTy+wT+V/1/xKSVQodGt7SA7bi97u8LmQwMTX39+07y1MHUd5IqvDoh++57cB6lovbD1cWRdPCyPlIPtlJng1jQNSGf1PXARE2z+KB5JUNHssGYZ8lM3eb9nh9tioVoVAcKnepSSa3l0Tjjj3rSw06hpetFFOandt1wlQ9+iEtGw9diB38PlVSy/doXgAUiycqmWtg5QILNK/jYFwnlC6tgwpvG1eqYMLK7LmqSRMOZgl/ehpjqsDM0U6+5tfOWgHm/KIJ0x99QCpRtdg== 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)(20161123555025)(20161123558100)(20161123564025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:VI1PR0502MB3664; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:VI1PR0502MB3664; X-Forefront-PRVS: 04772EA191 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(346002)(39860400002)(376002)(189002)(199003)(50466002)(97736004)(66066001)(478600001)(189998001)(36756003)(33026002)(25786009)(7736002)(316002)(107886003)(16586007)(4326008)(575784001)(86362001)(50226002)(53936002)(16526018)(101416001)(106356001)(5660300001)(2906002)(5003940100001)(69596002)(47776003)(6116002)(3846002)(68736007)(105586002)(81156014)(8936002)(81166006)(21086003)(305945005)(55016002)(4720700003)(2950100002)(76176999)(50986999)(6916009)(6666003)(48376002)(8676002)(33646002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0502MB3664; H:mellanox.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A: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; VI1PR0502MB3664; 23:0W+xo8/t5oHVVRuehMbf0vxdeOV7zFs0dzY+dJf?= =?us-ascii?Q?G6tjxIwSbV/MiRXPcZgUWUm5x2RE28JdCFko1/0vRHskFvCMs+wCqy7w64lJ?= =?us-ascii?Q?Prq+vqPIr+oP4kJNsOY234Js7JgHcKAnhRyu7hzsDc+xv3KpekesW5ncFiWk?= =?us-ascii?Q?ntflr0jp9caQGIMm7lmwuS97h8eQno3SkwuxOxAssK0jBe427Tmp27mxBYyK?= =?us-ascii?Q?rm6ZO8x1xN/GyGldqNutPWufflW9KAsgywDzGknufikdEmj2LPpnX2HKMFA9?= =?us-ascii?Q?EoBwlUmu5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Z7u8P5AQ0?= =?us-ascii?Q?mrWSoL7FNhzZSxvA=3D?= X-Microsoft-Exchange-Diagnostics: 1; VI1PR0502MB3664; 6:MK0jhLgKcwG2qoz9KoYlMOG+I1fZltFFgf0Lk7KnGJvpAN0MWO8BcpocZ2m5h+N6vwkuMa/cHCMgOXXnBFV7uth/zHQ7nxb10uVdtVm5uXqCyUMsBeTQ3vRSg8+Tn8fhZOyWIp/pfGwelVz//Cf3epb1G3H8zDTdrQcuw7rGlpP2HIEctqzRYMvPQzIxWICIpV9YpTAycqYARSvnsurBWNf/uvoouLtfZ4G6xKeZy5aXvb+WSoQpgeE7vjF9giDf9xbdoz4HZE2imGCXGqvp9DXBtifqYwOgOjT4okkegaCaaoPELIx6CI8RPQup0XJCSHQVM6qRUloNkfoKF9eCku3GcyILL+szIWZgF7njVsI=; 5:AUmX93UBwT26/oregNRe2TUW8IMDyxCRYtMTyX7OaqaoWtmO8Yu8LunG0wvos0tSNJcggFd8VUl/SRp4kNQf7eyBkZ4+gf7TsCJlzeD8R4SDFGpkxfWrw+itUTVmTJutmodqrcL2hgU58xZ9y7z0JT1P715awLDXjhnv7B4MW48=; 24:cc1QsvKCNBhcf5IASta79tOaXp9PsjHg0rXGNaAv0IL7nDViZW+NKeDy7wegLhJtz12xeNViCN64Kv5vPgSyZYanStaWYiQw7gQ52GGHsu0=; 7:Kws9c/hemf8yseSFKXGBcvn5zbQ7Rn+4K7akiZdJ8HDY33afnVsTHjmceaoBCBtygd4X6UHq0EusivRsPzijlnTvhwCc+uBYGqtaIJFUqjFAiYpAUmgsvuh/u45URzJ0FzpVSP+a9XJBjp6t5XKZ9e1Y86/wiA4pXiUj+hXmUNU+2ks6SNXaPLl23dDw/xewLIKUny1kO4JkX9rTAtYbt2VazX/mrpgF0qtonKUS7czTQJAqlqA3x1teUtsKAI19 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2017 18:21:54.5960 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 950f528f-0139-4abd-5ba8-08d5208c440b X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0502MB3664 Subject: [dpdk-dev] [PATCH v4 2/8] 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: Tue, 31 Oct 2017 18:21:57 -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 | 47 ++++++++++++++++++++++++++++++++++++ drivers/net/mlx4/mlx4_rxtx.c | 57 -------------------------------------------- drivers/net/mlx4/mlx4_rxtx.h | 31 +++++++++++++++++++++++- 4 files changed, 79 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..75ee32f 100644 --- a/drivers/net/mlx4/mlx4_mr.c +++ b/drivers/net/mlx4/mlx4_mr.c @@ -55,6 +55,7 @@ #include #include +#include "mlx4_rxtx.h" #include "mlx4_utils.h" struct mlx4_check_mempool_data { @@ -181,3 +182,49 @@ 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 79c7fa2..3b5faa1 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..185dbdf 100644 --- a/drivers/net/mlx4/mlx4_rxtx.h +++ b/drivers/net/mlx4/mlx4_rxtx.h @@ -165,7 +165,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 +181,34 @@ 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) { + /* MP found MP. */ + return txq->mp2mr[i].lkey; + } + } + return mlx4_txq_add_mr(txq, mp, i); +} + #endif /* MLX4_RXTX_H_ */ -- 1.8.3.1