From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0089.outbound.protection.outlook.com [104.47.1.89]) by dpdk.org (Postfix) with ESMTP id DD3F65689 for ; Thu, 28 Jun 2018 09:13:14 +0200 (CEST) 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:X-MS-Exchange-SenderADCheck; bh=p/xvhtwsMSNaYifBU6pbgJ/eLqfDmy9NzXLv7iU2RSE=; b=Rc2UBWfw3FK4VRojR0BU73OtQgaxRRnOijVSuh0eWzMtKx3rFIpFBXRDUT7JSsR6OdKsALL1QM3LNXyNsSpfXhFZ2Yoi0s33P/pHtdsGrAC45y3tpSo0LGIFqmUnDqy5vBlkSbj8FHx+mrHcT3VY7y95Vxj7/dilQa81ehmDlOU= Received: from localhost.localdomain (37.142.13.130) by VI1PR05MB4447.eurprd05.prod.outlook.com (2603:10a6:803:43::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.906.24; Thu, 28 Jun 2018 07:13:11 +0000 From: Moti Haimovsky To: yskoh@mellanox.com, adrien.mazarguil@6wind.com Cc: dev@dpdk.org, Moti Haimovsky Date: Thu, 28 Jun 2018 10:12:49 +0300 Message-Id: <1530169969-6708-1-git-send-email-motih@mellanox.com> X-Mailer: git-send-email 1.7.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: HE1PR0701CA0060.eurprd07.prod.outlook.com (2603:10a6:3:9e::28) To VI1PR05MB4447.eurprd05.prod.outlook.com (2603:10a6:803:43::10) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1217e6dc-db75-4440-4495-08d5dcc69c5a X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652034)(8989117)(5600026)(711020)(48565401081)(2017052603328)(7153060)(7193020); SRVR:VI1PR05MB4447; X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4447; 3:BOAggK3G3XFqWZrhuoPYIixTnopXFdJR5nu0BthOeUyV3gAJx92gCihQnJF9rd3goNrIria7zZHr8BaK8X+MFylQ2471Y//OvItwtwaio6MP5HOuikeoTe21qc2El82QRApqOA9HI5D65FUQYsRnnig2nD7YLOMfA5A8v9PSgg6uZse1j5O7RFUR/6PLyQmLK472XQI0TRaqyq5CQ72mepAJoChb3U2aJ9YHtp39HjKxhzuyHS4vcGsfxQXuCqmQ; 25:B5paE02OJV0fgRCqTU+e9iYj2/Tw8qbi0FYE6994XOZvVvVcBj6RwI3K1afj9KV6XMVFr8cOXlQfSfQEXIioFDbGNfbvEUJUCBs2JhkcTs5eOKYUIIyIps/CjFvuv6oTfg9ttFhLEDHEskc8pLDz1/E1XY4MkTDNPi5MfJf5gqlJn2oz5dyblV4CBJk/CwKwoIewepm9hWDDbvo95mR5BdkrcADb5Kc6ywIXsBCQ137ITfzcjkJEGLLuXX/ggtAkv6ejoBc1NxZBGVJI+TI/vFHqthZk9ZKrICf24ywSo5TybJ7ck9vRP1Uq4mxuiFrbNWhlvhULSwkXs0OodSfSUQ==; 31:7S4XMZ6eW4jAgiy1hUoSzCVUnfmDI2dfEtvCs1oqQYP9+q4o36IncmB5vy0ioQ2Rt1BW+E08a2KV1b2CTY7GLSHPx0ZTIZgA+eV4qR0Tgerau32isJGHVP/bLhdtRtdI1jqEbhbdamFtUyUJbBiDCgWNFL8UnZu3Wn4IBuYs9ILcjIJ41L5CYwkf60PqiBobsaWDXR7hGhix4rzMUqZhPfswzwk5RaQoTRcrHdn3trw= X-MS-TrafficTypeDiagnostic: VI1PR05MB4447: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4447; 20:YiCo98c1siM2tnSxyvEgZqjjmA0h+r2rRDPG1AxU9JkXlOpN2S28re/qmi6QdncZOJt20F2tJ1qL+8G4FjkWK5VCNhFUxQn40XmK7+1y4f1Gv9HkUZRgnOQGI3422eHGP8fXsqwvRW/r5VQFw8LCHZfgX5YQKnGp1limEuQQhl2yO8M7N8fd1MldzmJxXWYorKKd32RBZYkVDx0fTdg8VCON2cGWwZYHwYrtmMDqrqpcBt14hiEpqCiRx4tszAudYS3bT5bZL7Vificg6X1/QfjJBidYZbdhScIE94maPsqpAhLNHyKquPx1I3HVKUmGNSUfC1JJCguDN0PRaIj0cMRDxKJhzUdVF2X30z0OqNgNcECFWkzH/RHT4lnPXV9jaMqH3LeTcVULiijK9Sb6JoVaaHTV+fSBYj2BHyoezwn/z+Wkk8RNYMrdfBsU1uaFfJ5Jg/VnaoY9N44XAm7pFZYTGPo0RG5mH7yLuY+vSALb/Asy46b6RtI+gZyhJ/Wh; 4:b6vanO1roOJ08caFrKi+le4q6x0APBOAz4ViFywmVEYoJsljFSxINW0mbd0fkbYXyld9ZW9Fib5K9KVjgnTtcjd18lqEDLwlw8unpq3n4stc8GBKdnMGhH2hOqii2uEipH9nEQA7Yw7cJEMblDbdTP4waPrTrpY82QTqqcL4wyKxE98doCAi7+WSc2oTYTCfLPsk0Fl2Is9x1PGsQ/+ACI4ekrvVDkZA3uXmHFUzrfMWhi/yftDF8AqAlCxZsja0EfQlJKtMPM2upFSLPl5SjCQqYW5AvF2MtU6e8K894Uq0ykEV+jBt0wYhnVYRnerc23SnINtCf3NRWfb43S30DQy4gjrzwmYJMBQqj/CWuD6v+cdAVrUHFEDRgjSgIYMT X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(275740015457677)(111885846020525)(84791874153150); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3002001)(3231254)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(20161123560045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011)(7699016); SRVR:VI1PR05MB4447; BCL:0; PCL:0; RULEID:; SRVR:VI1PR05MB4447; X-Forefront-PRVS: 0717E25089 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(366004)(136003)(376002)(39860400002)(396003)(346002)(189003)(199004)(305945005)(7736002)(316002)(6346003)(8676002)(81156014)(16586007)(81166006)(51416003)(52116002)(25786009)(6506007)(386003)(26005)(478600001)(2906002)(68736007)(6666003)(575784001)(86362001)(50226002)(1857600001)(8936002)(16526019)(5660300001)(36756003)(6486002)(6306002)(6512007)(50466002)(106356001)(107886003)(14444005)(48376002)(486006)(476003)(956004)(2616005)(53936002)(105586002)(97736004)(4326008)(66066001)(3846002)(6116002)(47776003)(966005); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB4447; H:localhost.localdomain; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=motih@mellanox.com; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR05MB4447; 23:UTePNMK8AiynDARVWuO/0P/5EIpNR8Knm6gLQvpFW?= =?us-ascii?Q?1XMqChA9G6H9bKpoUj0n/+9SELTDHtiGWFKMVyNoRQl7nCsI5aUwadF2jVZ7?= =?us-ascii?Q?uT0ZdMA3Xlq4BvVxTn0P0rtfM6oTKZZeOWMJ28m6MV8lqQNescfManwvHo3L?= =?us-ascii?Q?neVIjGOyu0MU0lzq3hl+2g99bFH2dHc28rzBADuua3b1KSxV8I1GwhMCiFea?= =?us-ascii?Q?9rmgelkV8D5QckMNAn8XNnF8sgbmbI/9XsyyiCU/s9POHTzxEe3gyPETmv47?= =?us-ascii?Q?Q34i6ZFKeNkRi5+lXlJpolEqa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maqx51JOuPb4z23NPTFk7Zm2YFM7V77pWw3cxWbIZx7n3W5k3y0Mv88Yw4Glo0kzjhaCQcgTyohcfNZCyK9sY=; 24:7W3XQEWe7G0P1OCLBFtGflfFkON3hUPyOtnjSOp8CPPqgxnGRrNfceo627ju44ir7UBo3TUwQ99IU72dUXvsKiAQAfMC9PnN26Sz+5lBeRk= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4447; 7:Jzv7U1ZsMCYoofE5ZBJFDUHGEnY7ZeLlaRW++Qm1wc0/zaeECwlp3pVbQJqeRXP4TRbhV2vuhYWXnXmuT1iSgLf68ryZzCCDO6oTjV3fhMcvk81HpOLx2HN3qRY4LHzUbsMm0rTwKV9BaHJzkFRsh1dyUIrQMVGglWyrk2ADpCkaUCzvVsJLrvJbVi/6FPN6l0yfLZhSb1wVMoG2eB9Sz/jsyNfutem4KOVvjFJpDgW04JHsO/TR09tBnmnfW3v0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jun 2018 07:13:11.6382 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1217e6dc-db75-4440-4495-08d5dcc69c5a X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB4447 Subject: [dpdk-dev] [PATCH] net/mlx5: add support for 32bit systems 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: Thu, 28 Jun 2018 07:13:15 -0000 This patch adds support for building and running mlx5 PMD on 32bit systems such as i686. The main issue to tackle was handling the 32bit access to the UAR as quoted from the mlx5 PRM: QP and CQ DoorBells require 64-bit writes. For best performance, it is recommended to execute the QP/CQ DoorBell as a single 64-bit write operation. For platforms that do not support 64 bit writes, it is possible to issue the 64 bits DoorBells through two consecutive writes, each write 32 bits, as described below: * The order of writing each of the Dwords is from lower to upper addresses. * No other DoorBell can be rung (or even start ringing) in the midst of an on-going write of a DoorBell over a given UAR page. The last rule implies that in a multi-threaded environment, the access to a UAR page (which can be accessible by all threads in the process) must be synchronized (for example, using a semaphore) unless an atomic write of 64 bits in a single bus operation is guaranteed. Such a synchronization is not required for when ringing DoorBells on different UAR pages. Signed-off-by: Moti Haimovsky --- doc/guides/nics/features/mlx5.ini | 1 + doc/guides/nics/mlx5.rst | 11 +++++++ drivers/net/mlx5/mlx5.c | 8 ++++- drivers/net/mlx5/mlx5.h | 5 +++ drivers/net/mlx5/mlx5_defs.h | 18 ++++++++-- drivers/net/mlx5/mlx5_rxq.c | 6 +++- drivers/net/mlx5/mlx5_rxtx.c | 22 +++++++------ drivers/net/mlx5/mlx5_rxtx.h | 69 ++++++++++++++++++++++++++++++++++++++- drivers/net/mlx5/mlx5_txq.c | 13 +++++++- 9 files changed, 137 insertions(+), 16 deletions(-) diff --git a/doc/guides/nics/features/mlx5.ini b/doc/guides/nics/features/mlx5.ini index e75b14b..b28b43e 100644 --- a/doc/guides/nics/features/mlx5.ini +++ b/doc/guides/nics/features/mlx5.ini @@ -43,5 +43,6 @@ Multiprocess aware = Y Other kdrv = Y ARMv8 = Y Power8 = Y +x86-32 = Y x86-64 = Y Usage doc = Y diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst index 7dd9c1c..cb9d5d8 100644 --- a/doc/guides/nics/mlx5.rst +++ b/doc/guides/nics/mlx5.rst @@ -50,6 +50,8 @@ Features -------- - Multi arch support: x86_64, POWER8, ARMv8. +- Support for i686 is available only when working with + rdma-core version 18.0 or above, built with 32bit support. - Multiple TX and RX queues. - Support for scattered TX and RX frames. - IPv4, IPv6, TCPv4, TCPv6, UDPv4 and UDPv6 RSS on any number of queues. @@ -136,6 +138,11 @@ Limitations enabled (``rxq_cqe_comp_en``) at the same time, RSS hash result is not fully supported. Some Rx packets may not have PKT_RX_RSS_HASH. +- Building for i686 is only supported with: + + - rdma-core version 18.0 or above built with 32bit support. + - Kernel version 4.14.41 or above. + Statistics ---------- @@ -477,6 +484,10 @@ RMDA Core with Linux Kernel - Minimal kernel version : v4.14 or the most recent 4.14-rc (see `Linux installation documentation`_) - Minimal rdma-core version: v15+ commit 0c5f5765213a ("Merge pull request #227 from yishaih/tm") (see `RDMA Core installation documentation`_) +- When building for i686 use: + + - rdma-core version 18.0 or above built with 32bit support. + - Kernel version 4.14.41 or above. .. _`Linux installation documentation`: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/plain/Documentation/admin-guide/README.rst .. _`RDMA Core installation documentation`: https://raw.githubusercontent.com/linux-rdma/rdma-core/master/README.md diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index f0e6ed7..5d0f706 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -567,7 +567,7 @@ rte_memseg_walk(find_lower_va_bound, &addr); /* keep distance to hugepages to minimize potential conflicts. */ - addr = RTE_PTR_SUB(addr, MLX5_UAR_OFFSET + MLX5_UAR_SIZE); + addr = RTE_PTR_SUB(addr, (uintptr_t)(MLX5_UAR_OFFSET + MLX5_UAR_SIZE)); /* anonymous mmap, no real memory consumption. */ addr = mmap(addr, MLX5_UAR_SIZE, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); @@ -953,6 +953,12 @@ priv->port = port; priv->pd = pd; priv->mtu = ETHER_MTU; +#ifndef RTE_ARCH_64 + /* Initialize UAR access locks for 32bit implementations. */ + rte_spinlock_init(&priv->uar_lock_cq); + for (i = 0; i < MLX5_UAR_PAGE_NUM_MAX; i++) + rte_spinlock_init(&priv->uar_lock[i]); +#endif err = mlx5_args(&config, pci_dev->device.devargs); if (err) { err = rte_errno; diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 997b04a..2da32cd 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -198,6 +198,11 @@ struct priv { /* Context for Verbs allocator. */ int nl_socket; /* Netlink socket. */ uint32_t nl_sn; /* Netlink message sequence number. */ +#ifndef RTE_ARCH_64 + rte_spinlock_t uar_lock_cq; /* CQs share a common distinct UAR */ + rte_spinlock_t uar_lock[MLX5_UAR_PAGE_NUM_MAX]; + /* UAR same-page access control required in 32bit implementations. */ +#endif }; #define PORT_ID(priv) ((priv)->dev_data->port_id) diff --git a/drivers/net/mlx5/mlx5_defs.h b/drivers/net/mlx5/mlx5_defs.h index 5bbbec2..f6ec415 100644 --- a/drivers/net/mlx5/mlx5_defs.h +++ b/drivers/net/mlx5/mlx5_defs.h @@ -87,14 +87,28 @@ #define MLX5_LINK_STATUS_TIMEOUT 10 /* Reserved address space for UAR mapping. */ -#define MLX5_UAR_SIZE (1ULL << 32) +#define MLX5_UAR_SIZE (1ULL << (sizeof(uintptr_t) * 4)) /* Offset of reserved UAR address space to hugepage memory. Offset is used here * to minimize possibility of address next to hugepage being used by other code * in either primary or secondary process, failing to map TX UAR would make TX * packets invisible to HW. */ -#define MLX5_UAR_OFFSET (1ULL << 32) +#define MLX5_UAR_OFFSET (1ULL << (sizeof(uintptr_t) * 4)) + +/* Maximum number of UAR pages used by a port, + * These are the size and mask for an array of mutexes used to synchronize + * the access to port's UARs on platforms that do not support 64 bit writes. + * In such systems it is possible to issue the 64 bits DoorBells through two + * consecutive writes, each write 32 bits. The access to a UAR page (which can + * be accessible by all threads in the process) must be synchronized + * (for example, using a semaphore). Such a synchronization is not required + * when ringing DoorBells on different UAR pages. + * A port with 512 Tx queues uses 8, 4kBytes, UAR pages which are shared + * among the ports. + */ +#define MLX5_UAR_PAGE_NUM_MAX 64 +#define MLX5_UAR_PAGE_NUM_MASK ((MLX5_UAR_PAGE_NUM_MAX) - 1) /* Log 2 of the default number of strides per WQE for Multi-Packet RQ. */ #define MLX5_MPRQ_STRIDE_NUM_N 6U diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index 08dd559..820048f 100644 --- a/drivers/net/mlx5/mlx5_rxq.c +++ b/drivers/net/mlx5/mlx5_rxq.c @@ -643,7 +643,8 @@ doorbell = (uint64_t)doorbell_hi << 32; doorbell |= rxq->cqn; rxq->cq_db[MLX5_CQ_ARM_DB] = rte_cpu_to_be_32(doorbell_hi); - rte_write64(rte_cpu_to_be_64(doorbell), cq_db_reg); + mlx5_uar_write64(rte_cpu_to_be_64(doorbell), + cq_db_reg, rxq->uar_lock_cq); } /** @@ -1445,6 +1446,9 @@ struct mlx5_rxq_ctrl * tmpl->rxq.elts_n = log2above(desc); tmpl->rxq.elts = (struct rte_mbuf *(*)[1 << tmpl->rxq.elts_n])(tmpl + 1); +#ifndef RTE_ARCH_64 + tmpl->rxq.uar_lock_cq = &priv->uar_lock_cq; +#endif tmpl->idx = idx; rte_atomic32_inc(&tmpl->refcnt); LIST_INSERT_HEAD(&priv->rxqsctrl, tmpl, next); diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c index a7ed8d8..ec35ea0 100644 --- a/drivers/net/mlx5/mlx5_rxtx.c +++ b/drivers/net/mlx5/mlx5_rxtx.c @@ -495,6 +495,7 @@ volatile struct mlx5_wqe_ctrl *last_wqe = NULL; unsigned int segs_n = 0; const unsigned int max_inline = txq->max_inline; + uint64_t addr_64; if (unlikely(!pkts_n)) return 0; @@ -711,12 +712,12 @@ ds = 3; use_dseg: /* Add the remaining packet as a simple ds. */ - addr = rte_cpu_to_be_64(addr); + addr_64 = rte_cpu_to_be_64(addr); *dseg = (rte_v128u32_t){ rte_cpu_to_be_32(length), mlx5_tx_mb2mr(txq, buf), - addr, - addr >> 32, + addr_64, + addr_64 >> 32, }; ++ds; if (!segs_n) @@ -750,12 +751,12 @@ total_length += length; #endif /* Store segment information. */ - addr = rte_cpu_to_be_64(rte_pktmbuf_mtod(buf, uintptr_t)); + addr_64 = rte_cpu_to_be_64(rte_pktmbuf_mtod(buf, uintptr_t)); *dseg = (rte_v128u32_t){ rte_cpu_to_be_32(length), mlx5_tx_mb2mr(txq, buf), - addr, - addr >> 32, + addr_64, + addr_64 >> 32, }; (*txq->elts)[++elts_head & elts_m] = buf; if (--segs_n) @@ -1450,6 +1451,7 @@ unsigned int mpw_room = 0; unsigned int inl_pad = 0; uint32_t inl_hdr; + uint64_t addr_64; struct mlx5_mpw mpw = { .state = MLX5_MPW_STATE_CLOSED, }; @@ -1586,13 +1588,13 @@ ((uintptr_t)mpw.data.raw + inl_pad); (*txq->elts)[elts_head++ & elts_m] = buf; - addr = rte_cpu_to_be_64(rte_pktmbuf_mtod(buf, - uintptr_t)); + addr_64 = rte_cpu_to_be_64( + rte_pktmbuf_mtod(buf, uintptr_t)); *dseg = (rte_v128u32_t) { rte_cpu_to_be_32(length), mlx5_tx_mb2mr(txq, buf), - addr, - addr >> 32, + addr_64, + addr_64 >> 32, }; mpw.data.raw = (volatile void *)(dseg + 1); mpw.total_len += (inl_pad + sizeof(*dseg)); diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h index 0007be0..2448d73 100644 --- a/drivers/net/mlx5/mlx5_rxtx.h +++ b/drivers/net/mlx5/mlx5_rxtx.h @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include "mlx5_utils.h" #include "mlx5.h" @@ -115,6 +117,10 @@ struct mlx5_rxq_data { void *cq_uar; /* CQ user access region. */ uint32_t cqn; /* CQ number. */ uint8_t cq_arm_sn; /* CQ arm seq number. */ +#ifndef RTE_ARCH_64 + rte_spinlock_t *uar_lock_cq; + /* CQ (UAR) access lock required for 32bit implementations */ +#endif uint32_t tunnel; /* Tunnel information. */ } __rte_cache_aligned; @@ -196,6 +202,10 @@ struct mlx5_txq_data { volatile void *bf_reg; /* Blueflame register remapped. */ struct rte_mbuf *(*elts)[]; /* TX elements. */ struct mlx5_txq_stats stats; /* TX queue counters. */ +#ifndef RTE_ARCH_64 + rte_spinlock_t *uar_lock; + /* UAR access lock required for 32bit implementations */ +#endif } __rte_cache_aligned; /* Verbs Rx queue elements. */ @@ -348,6 +358,63 @@ uint16_t mlx5_rx_burst_vec(void *dpdk_txq, struct rte_mbuf **pkts, uint32_t mlx5_rx_addr2mr_bh(struct mlx5_rxq_data *rxq, uintptr_t addr); uint32_t mlx5_tx_addr2mr_bh(struct mlx5_txq_data *txq, uintptr_t addr); +/** + * Provide safe 64bit store operation to mlx5 UAR region for both 32bit and + * 64bit architectures. + * + * @param val + * value to write in CPU endian format. + * @param addr + * Address to write to. + * @param lock + * Address of the lock to use for that UAR access. + */ +static __rte_always_inline void +__mlx5_uar_write64_relaxed(uint64_t val, volatile void *addr, + rte_spinlock_t *lock __rte_unused) +{ +#ifdef RTE_ARCH_64 + rte_write64_relaxed(val, addr); +#else /* !RTE_ARCH_64 */ + rte_spinlock_lock(lock); + rte_write32_relaxed(val, addr); + rte_io_wmb(); + rte_write32_relaxed(val >> 32, + (volatile void *)((volatile char *)addr + 4)); + rte_spinlock_unlock(lock); +#endif +} + +/** + * Provide safe 64bit store operation to mlx5 UAR region for both 32bit and + * 64bit architectures while guaranteeing the order of execution with the + * code being executed. + * + * @param val + * value to write in CPU endian format. + * @param addr + * Address to write to. + * @param lock + * Address of the lock to use for that UAR access. + */ +static __rte_always_inline void +__mlx5_uar_write64(uint64_t val, volatile void *addr, rte_spinlock_t *lock) +{ + rte_io_wmb(); + __mlx5_uar_write64_relaxed(val, addr, lock); +} + +/* Assist macros, used instead of directly calling the functions they wrap. */ +#ifdef RTE_ARCH_64 +#define mlx5_uar_write64_relaxed(val, dst, lock) \ + __mlx5_uar_write64_relaxed(val, dst, NULL) +#define mlx5_uar_write64(val, dst, lock) __mlx5_uar_write64(val, dst, NULL) +#else +#define mlx5_uar_write64_relaxed(val, dst, lock) \ + __mlx5_uar_write64_relaxed(val, dst, lock) +#define mlx5_uar_write64(val, dst, lock) __mlx5_uar_write64(val, dst, lock) +#endif + #ifndef NDEBUG /** * Verify or set magic value in CQE. @@ -614,7 +681,7 @@ uint16_t mlx5_rx_burst_vec(void *dpdk_txq, struct rte_mbuf **pkts, *txq->qp_db = rte_cpu_to_be_32(txq->wqe_ci); /* Ensure ordering between DB record and BF copy. */ rte_wmb(); - *dst = *src; + mlx5_uar_write64_relaxed(*src, dst, txq->uar_lock); if (cond) rte_wmb(); } diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c index 669b913..dc786d4 100644 --- a/drivers/net/mlx5/mlx5_txq.c +++ b/drivers/net/mlx5/mlx5_txq.c @@ -255,6 +255,9 @@ struct mlx5_txq_ctrl *txq_ctrl; int already_mapped; size_t page_size = sysconf(_SC_PAGESIZE); +#ifndef RTE_ARCH_64 + unsigned int lock_idx; +#endif memset(pages, 0, priv->txqs_n * sizeof(uintptr_t)); /* @@ -281,7 +284,7 @@ } /* new address in reserved UAR address space. */ addr = RTE_PTR_ADD(priv->uar_base, - uar_va & (MLX5_UAR_SIZE - 1)); + uar_va & (uintptr_t)(MLX5_UAR_SIZE - 1)); if (!already_mapped) { pages[pages_n++] = uar_va; /* fixed mmap to specified address in reserved @@ -305,6 +308,12 @@ else assert(txq_ctrl->txq.bf_reg == RTE_PTR_ADD((void *)addr, off)); +#ifndef RTE_ARCH_64 + /* Assign a UAR lock according to UAR page number */ + lock_idx = (txq_ctrl->uar_mmap_offset / page_size) & + MLX5_UAR_PAGE_NUM_MASK; + txq->uar_lock = &priv->uar_lock[lock_idx]; +#endif } return 0; } @@ -511,6 +520,8 @@ struct mlx5_txq_ibv * rte_atomic32_inc(&txq_ibv->refcnt); if (qp.comp_mask & MLX5DV_QP_MASK_UAR_MMAP_OFFSET) { txq_ctrl->uar_mmap_offset = qp.uar_mmap_offset; + DRV_LOG(DEBUG, "port %u: uar_mmap_offset 0x%lx", + dev->data->port_id, txq_ctrl->uar_mmap_offset); } else { DRV_LOG(ERR, "port %u failed to retrieve UAR info, invalid" -- 1.8.3.1